
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 1.59 KB | hits: 22 | expires: Never
Android: Network Radio off before ACTION_SHUTDOWN event.Events order Changed in ICS
public class MyAppShutdown extends BroadcastReceiver{
private static final String TAG = "MyAppShutdown";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.v(TAG, "onReceive - ++ ENTER ++");
if (intent != null && intent.getAction().equals(Intent.ACTION_SHUTDOWN)){
Log.v(TAG, "onReceive - ***] SHUTDOWN [***");
// perhaps send a broadcast to your app via intent to perform a log out.
Intent intent = new Intent();
intent.addAction("intent.myapp.action.shutdown");
sendBroadcast(intent);
}
Log.v(TAG, "onReceive - ++ LEAVE ++");
}
}
<receiver android:name=".MyAppShutdown">
<intent-filter>
<action android:name="android.intent.action.SHUTDOWN"/>
</intent-filter>
</receiver>
public class myApp extends Activity{
private myAppBroadcastRcvr myAppRcvr = new myAppBroadcastRcvr();
@Override
public void onCreate(Bundle savedInstanceState){
IntentFilter filter = new IntentFilter();
filter.addAction("intent.myapp.action.shutdown");
registerReceiver(myAppRcvr, filter);
}
// Perhaps you have this
private void LogOff(){
}
class myAppBroadcastRcvr extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
if (intent.getAction().equals("intent.myapp.action.shutdown")){
LogOff();
}
}
}
}