我正在制作一个应用程序,我想在它第一次运行良好时显示通知,但第二次它没有更新通知中的列表。
public class StatusBar extends Activity {
NotificationManager mn;
static int uniqueId = 1394885;
static ArrayList<String> arrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent intent = getIntent();
arrayList = intent.getStringArrayListExtra("nameOfFilesCopied");
mn = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mn.cancel(uniqueId);
ahoo();
}
private void ahoo() {
// TODO Auto-generated method stub
Intent intent = new Intent("helpsettings.ListOfFilesCopied");
intent.putStringArrayListExtra("nameOfFilesCopied", arrayList);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
String body = "List of files that are copied by the connected person";
String title = "List Of Files Copied";
// need to craate a notification i.e what the time is
@SuppressWarnings("deprecation")
Notification n = new Notification(R.drawable.ic_launcher, body,
System.currentTimeMillis());
// add what details we want to our notification
n.setLatestEventInfo(this, title, body, pi);
n.defaults = Notification.DEFAULT_LIGHTS;
mn.notify(uniqueId, n);
finish();
}
第二次,当我放置 arrayList 并通过挂起的意图我调用下面的类时,挂起的意图发送上一个列表而不是第二个 itme 上的列表公共类 ListOfFilesCopied 扩展 ListActivity {
ArrayList<String> list;
private ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent intent = getIntent();
list = intent.getStringArrayListExtra("nameOfFilesCopied");
adapter = new MyAdapters(this, R.layout.ahoo, list);
setListAdapter(adapter);
}
/*
* (non-Javadoc)
*
* @see android.app.Activity#onBackPressed()
*/
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
list.clear();
}
/*
* (non-Javadoc)
*
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
}