views:

212

answers:

1

I have this Broadcast receiver registered

public class NotifyAlarmBroadcast extends BroadcastReceiver{
    public Context context;
    public static final String NOTI = "android.intent.action.MAIN";
// actually i want NOTI = "com.sumit.timekeeper.NotifyAlarm"
// this too is not working
// help me here please

@Override
public void onReceive(Context _context, Intent intent) {
    context = _context;
    Uri data = intent.getData();
    String reason = intent.getStringExtra("alarm_reason");
    Intent intentalarm = new Intent(NOTI, data);

    intentalarm.putExtra("reason", reason);
    context.startActivity(intentalarm);
}

}

and the manifest

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".TimeKeeperStartActivity"
        android:screenOrientation="portrait" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".NotifyAlarm"
        android:screenOrientation="portrait" android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="com.sumit.timekeeper.NotifyAlarm">
            </action>
        </intent-filter>
    </activity>

    <receiver android:name=".NotifyAlarmBroadcast">
        <intent-filter>
            <action android:name="com.sumit.timekeeper.NotifyAlarmBroadcast" />
        </intent-filter>
    </receiver>
</application>

but when the line reaches context.startActivity(intentalarm); the application crashes

may be it is where we pass first parameter to Intent, i'm not clear about please help me.

+1  A: 

Try to add the FLAG_ACTIVITY_NEW_TASK flag in your intent.

intentalarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ccheneson
This too didn't work for me. I think I'm not understanding the real behavior of BroadCasting. I'm trying to learn it after finding some nice tutorials. If you know any good blogs explaining BroadCasting in Android, please give me a link to it. Thanks again.
Sumit M Asok