我的Android应用程序被传递信息的意图调用(状态栏中的pendingintent).
当我按下主页按钮并通过按住主页按钮重新打开我的应用程序时,它再次调用了意图,并且仍然存在相同的附加功能.
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
这是不像它应该运行的代码
String imgUrl;
Bundle extras = this.getIntent().getExtras();
if(extras != null){
imgUrl = extras.getString("imgUrl");
if( !imgUrl.equals(textView01.getText().toString()) ){
imageView.setImageDrawable( getImageFromUrl( imgUrl ) );
layout1.setVisibility(0);
textView01.setText(imgUrl);//textview to hold the url
}
}
Run Code Online (Sandbox Code Playgroud)
我的意图是:
public void showNotification(String ticker, String title, String message,
String imgUrl){
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(ns);
int icon = R.drawable.icon; // icon from resources
long when = System.currentTimeMillis(); // …Run Code Online (Sandbox Code Playgroud)