我试图存储一个arraylist onSavedInstanceState()
的值并在onCreate方法中获取数组列表中的值,但它引发了一个像无法暂停活动的爱
这是我的代码
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putParcelable("Old", (Parcelable) profileDetails );
super.onSaveInstanceState(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
在我的 onCreate()
if (savedInstanceState != null) {
profileDetails= (ArrayList<ProfileDetails>)savedInstanceState.getParcelable("Old");
}
else {
profileDetails = GetSearchResults();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作自定义通知,但无法解决此问题.
public void remNotifyClicked (View view){
notification.setSmallIcon(R.drawable.ic_launcher);
notification.setTicker("Ticker");
notification.setContentTitle("Notification");
notification.setContentText("Congratulation!");
notification.setWhen(System.currentTimeMillis());
Intent i = new Intent(this, SecondActivity.class);
notification.setContentIntent( new PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT));
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(uniqueId, notification.build());
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,"getActivity"显示为错误(红色),并表示它无法解析符号(当悬停在它上面时).谢谢.
PS:我使用的是Android Studio.
我正在开发一个 Android 屏幕小部件。默认大小(如果我将 Widget 从 Widget-List 拖放到我的主屏幕上)设置为 3x3,但我没有找到可以更改它的位置。谁能解释我如何在另一个值上设置默认值?