Can android application have only broadcast recevier and service without activity ? If this is possible how can i invoke broadcast receiver ? Android system automatically in
Starting with Honeycomb, BroadcastReceivers are installed in a stopped state and will not trigger until an application has actually run, i.e. you will need an activity to have run at least once. This is explained in depth in this Commonsware blog post:
Broadcast Regression Confirmed
Android 3.1
public class FlashApkclass extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
}
}
In your manifest.xml file set your android:name as like
<receiver android:name="com.example.ambrecentral.server.FlashApkclass"
android:exported="false">
<intent-filter>
// register you broadcast receiver to list broadcast
<action android:name="com.example.android.APP_CLOUD_DELETE_APK"/>
</intent-filter>
</receiver>
and if you want to broadcast
broadcast.setAction(BROADCAST_ACTION);
sendBroadcast(broadcast);
where BROADCAST_ACTION is
public static String BROADCAST_ACTION = "com.example.android.APP_CLOUD_DELETE_APK";