2012-03-23 45 views
0

我想從服務中調用android設置活動,我已經使用此代碼,但它不起作用。服務中的活動?

final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.fuelgauge.PowerUsageSummary"); 
intent.setComponent(cn); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
+1

添加此標誌'intent.setFlags(Intent.FLAG_FROM_BACKGROUND);' – 2012-03-23 13:18:39

+0

使用'ADB logcat',DDMS,或在Eclipse中logcat的角度來考察logcat的看當「不工作」時出現什麼消息。 – CommonsWare 2012-03-23 13:19:53

回答

1

試試這個:

final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.fuelgauge.PowerUsageSummary"); 
intent.setComponent(cn); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.setFlags(Intent.FLAG_FROM_BACKGROUND); 
startActivity(intent);