Search code examples
javaandroidservicebroadcastreceiverruntime-error

android unable to start receiver not yet implemented


I am wanting to start a service (CheckTime) when the phone finishes booting. This appears to work, but my app immediately crashes. I get the following error "java.lang.RuntimeException: Unable to start receiver com.example.alarmtest.MyReceiver: java.lang.UnsupportedOperationException: Not yet implemented". I have been unsuccessful in my attempts to solve this problem. I am unsure if I have left something out of the manifest or not (I am fairly new to developing for android). This is my code for MyReceiver. (the log.d for this appears)

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");
        }
}

and the code for CheckTime (the log.d for this never appears)

public class CheckTime {
      public void loglab(){
      Log.d("evan alarm", "We are now in CheckTime");
      }
}

and finally the manifest.

<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>

Solution

  •    throw new UnsupportedOperationException("Not yet implemented");
    

    That's the last line of your receiver. You're throwing it yourself.