調用服務時的錯誤是我用來從我的活動調用服務的代碼。 我想在進度條達到最大值時調用該服務。什麼纔是正確的做法呢?我的進度條達到最大值,然後我得到錯誤....以下是從活動
Handler progressHandler = new Handler()
{
public void handleMessage(Message msg)
{
if (dialog.getProgress() == dialog.getMax())
{
//Log.d(TAG, "onClick: stopping srvice");
// stopService(new Intent(oddg.this, MyService.class));
Log.d(TAG, "onClick: starting service");
startService(new Intent(oddg.this, MyService.class));
}
dialog.incrementProgressBy(increment);
}
};
日誌:
ERROR/AndroidRuntime(725): java.lang.RuntimeException: Unable to create service org.androidpeople.dialog.MyService: android.util.AndroidRuntimeException:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.
這是什麼錯誤? – Reno 2011-03-15 06:32:21
錯誤/ AndroidRuntime(725):java.lang.RuntimeException:無法創建服務org.androidpeople.dialog.MyService:android.util.AndroidRuntimeException:從Activity上下文外調用startActivity()需要FLAG_ACTIVITY_NEW_TASK標誌。這是我在日誌文件中得到的錯誤...... – Smith 2011-03-15 06:35:52
@reno告訴我要做什麼? – Smith 2011-03-15 06:47:52