【发布时间】:2015-12-01 02:53:24
【问题描述】:
您好,我正在开发的应用程序包含来自解析的 json 通知,应用程序将其存储在 SQLite 中在我的代码的主要活动中显示它
public class Receiver extends ParsePushBroadcastReceiver {
@Override
public void onPushReceive(Context context, Intent intent) {
super.onPushReceive(context, intent);
Log.e("Push", "Clicked");
Intent i = new Intent(context, splashscreen.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Log.d("Alert: ", "Inserting from onReceive");
Bundle extras = intent.getExtras();
String jsonData = extras.getString("com.parse.Data");
JSONObject jsonObject;
try {
jsonObject = new JSONObject(jsonData);
String alert = jsonObject.getString("alert");
Log.d("Insert: ",alert);
String Message = jsonObject.getString("Message");
Log.d("Title: ",Message);
String Date = jsonObject.getString("Date");
Log.d("Date: ",Date);
DatabaseHandler db=new DatabaseHandler(context);
db.addnotification(new notification(alert,Message,Date));
Log.d("Reading: ", "Reading all notifications..");
List<notification> notifications = db.getAllnotifications();
for (notification cn : notifications) {
String log = "Id: "+cn.getID()+" ,Title: " + cn.gettitle() + " ,Message: " + cn.getmessage()+ " ,Date: " + cn.gettimedate();
// Writing notifications to log
Log.d("Name: ", log);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
【问题讨论】:
-
您能否正确地提供一些关于您想要实现的目标的见解?您面临的任何错误和问题都可以帮助社区了解您实际遇到的问题
-
我想在列表视图中显示存储在sqlite中的json数据(其中“警报”“消息”“日期”)
-
@Fabiano Francesconi
-
你可以从数据库中取回来,然后显示出来。你在寻找什么问题?
-
如何找回它...@Diyoda
标签: android sqlite listview adapter