Android Open Source - CSCI567---Workspace Reboot Receiver






From Project

Back to project page CSCI567---Workspace.

License

The source code is released under:

MIT License

If you think the Android project CSCI567---Workspace listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package csci567.eventreceiver;
//from  ww w.j  a  va  2s.  co  m
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log;


public class RebootReceiver extends BroadcastReceiver{
  
  private NotificationManager mNotificationManager;
  public static final int NOTIFICATION_ID = 1;
  
  private static final String TAG = "EventReciever:RebootReceiver";
     @Override
  public void onReceive(Context context, Intent intent) {
       if(intent.getAction() != null){
        if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
          Log.d(TAG,"Reboot Succeded");
          sendNotification(context, "Reboot Occurred");
        }
      }       
  }

    
     private void sendNotification(Context context, String msg) {
        mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
            new Intent(context, MainActivity.class), 0);

        NotificationCompat.Builder mBuilder = 
          new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(context.getString(R.string.reboot_alert))
            .setStyle(new NotificationCompat.BigTextStyle()
            .bigText(msg))
            .setContentText(msg);

        mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}




Java Source Code List

com.example.linearlayoutexample.MainActivity.java
com.example.relativelayoutexample.MainActivity.java
csci567.FragmentExample.Fragmentmanageractivity.java
csci567.FragmentExample.MainActivity.java
csci567.FragmentExample.MyFragment.java
csci567.FragmentExample.MyStaticFragment.java
csci567.alarmexample.MainActivity.java
csci567.alarmexample.SampleAlarmReceiver.java
csci567.asynctaskexample.MainActivity.java
csci567.buttonexample.MainActivity.java
csci567.checkboxexample.MainActivity.java
csci567.doodleexample.MainActivity.java
csci567.doodleexample.SampleAlarmReceiver.java
csci567.doodleexample.SampleBootReceiver.java
csci567.doodleexample.SampleSchedulingService.java
csci567.eventreceiver.DataReceiver.java
csci567.eventreceiver.MainActivity.java
csci567.eventreceiver.RebootReceiver.java
csci567.helloworld.MainActivity.java
csci567.simpledbexample.DBHelper.java
csci567.simpledbexample.MainActivity.java
csci567.suggestionapp.MainActivity.java
csci567.writefile.MainActivity.java
org.ndeftools.boilerplate.AndroidNfcActivity.java
org.ndeftools.boilerplate.DefaultNfcBeamWriterActivity.java
org.ndeftools.boilerplate.DefaultNfcReaderActivity.java
org.ndeftools.boilerplate.DefaultNfcTagWriterActivity.java
org.ndeftools.boilerplate.NdefRecordAdapter.java
org.ndeftools.nfcdemo.TagViewer.java
org.ndeftools.nfcdemo.simulator.FakeTagsActivity.java
org.ndeftools.nfcdemo.simulator.MockNdefMessages.java