2009年2月4日 星期三

ProgressDialog無法在Activity建立過程中使用

居然會因為底層的問題沒辦法在Activity的onCreate() onStart()之類的途中使用 orz
就算要插一個Activity在中間也有資料傳輸的問題,直接改layout更是一整個suck
不是我要講,這還真的滿鳥的…………

所以剩下的辦法就是改用notification:

Context ctx = getApplicationContext();
final NotificationManager nm = (NotificationManager) getSystemService("notification");
Notification n = new Notification(R.drawable.icon,
getString(R.string.loading_message), System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0,
new Intent(ctx, FileBrowserActivity.class), 0);
n.flags = Notification.FLAG_NO_CLEAR;
n.setLatestEventInfo(ctx, getString(R.string.app_name),
getString(R.string.loading_message), contentIntent);
nm.notify(LOADING_NOTIFICATION, n);

沒有留言:

張貼留言