Guest User

Untitled

a guest
Aug 11th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. Android: Network Radio off before ACTION_SHUTDOWN event.Events order Changed in ICS
  2. public class MyAppShutdown extends BroadcastReceiver{
  3. private static final String TAG = "MyAppShutdown";
  4. @Override
  5. public void onReceive(Context context, Intent intent) {
  6. // TODO Auto-generated method stub
  7. Log.v(TAG, "onReceive - ++ ENTER ++");
  8. if (intent != null && intent.getAction().equals(Intent.ACTION_SHUTDOWN)){
  9. Log.v(TAG, "onReceive - ***] SHUTDOWN [***");
  10. // perhaps send a broadcast to your app via intent to perform a log out.
  11. Intent intent = new Intent();
  12. intent.addAction("intent.myapp.action.shutdown");
  13. sendBroadcast(intent);
  14. }
  15. Log.v(TAG, "onReceive - ++ LEAVE ++");
  16. }
  17. }
  18.  
  19. <receiver android:name=".MyAppShutdown">
  20. <intent-filter>
  21. <action android:name="android.intent.action.SHUTDOWN"/>
  22. </intent-filter>
  23. </receiver>
  24.  
  25. public class myApp extends Activity{
  26. private myAppBroadcastRcvr myAppRcvr = new myAppBroadcastRcvr();
  27. @Override
  28. public void onCreate(Bundle savedInstanceState){
  29. IntentFilter filter = new IntentFilter();
  30. filter.addAction("intent.myapp.action.shutdown");
  31. registerReceiver(myAppRcvr, filter);
  32. }
  33. // Perhaps you have this
  34. private void LogOff(){
  35. }
  36. class myAppBroadcastRcvr extends BroadcastReceiver{
  37. @Override
  38. public void onReceive(Context context, Intent intent){
  39. if (intent.getAction().equals("intent.myapp.action.shutdown")){
  40. LogOff();
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment