SMS app.
I've got the waking of the phone on receiving an SMS.
Here is the code.
SMS_Alert_Receiver.java
- Code: Select all
package com.grimx.SMSALERT;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.PowerManager;
import android.widget.Toast;
public class SMS_Alert_Receiver extends BroadcastReceiver{
PowerManager.WakeLock wl;
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
"Incoming txt-mesg");
wl.acquire(60000);
Intent myIntent = new Intent(context, SMS_Alert.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
SMS_Alert.java
- Code: Select all
package com.grimx.SMSALERT;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class SMS_Alert extends Activity {
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
onDestroy();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
finish();
}
}
How do I call up the default SMS app displaying the current message??

