我想在手機完成啓動時啓動service
(檢查時間)。這似乎工作,但我的應用程序立即崩潰。我收到以下錯誤「java.lang.RuntimeException: Unable to start receiver com.example.alarmtest.MyReceiver: java.lang.UnsupportedOperationException: Not yet implemented
」。我試圖解決這個問題一直沒有成功。我不確定我是否從manifest
中遺漏了某些東西(我對於開發Android相當新穎)。 這是我MyReceiver的代碼。 (出現這個log.d)android無法啓動接收器尚未實現
public class MyReceiver extends BroadcastReceiver {
public MyReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, CheckTime.class);
context.startService(startServiceIntent);
Log.d("evan alarm", "Started on Launch, android autostart");
throw new UnsupportedOperationException("Not yet implemented");
}
}
和(從未出現log.d此),用於檢查時間碼
public class CheckTime {
public void loglab(){
Log.d("evan alarm", "We are now in CheckTime");
}
}
,最終清單。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alarmtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service
android:name="com.example.alarmtest.MyService" >
<intent-filter
android:label="com.example.alarmtest.MyService">
</intent-filter>
</service>
<service android:name="com.example.alarmtest.CheckTime" />
<activity
android:name="com.example.alarmtest.AlarmActivity"
android:label="@string/title_activity_alarm" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.alarmtest.ChangeTime"
android:label="@string/title_activity_change_time" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.AlarmTest.AlarmActivity" />
</activity>
<receiver
android:name="com.example.alarmtest.MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
......不,我覺得很傻。 – Mr404servererror
@ Mr404servererror發生在我們身上! – ninehundredt
Lol Same,這就是爲什麼來到這裏。 –