Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Start Default SMS app problem

Start Default SMS app problem

Put your problem here if it does not fit any of the other categories.

Start Default SMS app problem

Postby grimx » Wed Feb 22, 2012 9:51 pm

What I'm trying to do is, wake the phone upon receiving a SMS and then start the default
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??
grimx
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Dec 05, 2009 12:47 am

Top

Re: Start Default SMS app problem

Postby grimx » Wed Feb 22, 2012 11:03 pm

I got it.

Here is the code of my app
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.telephony.SmsMessage;
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);
         
         
         //Get the SMS message
         Bundle bundle = intent.getExtras();
         SmsMessage[] msgs = null;
         if(bundle != null) {
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];
            for(int i = 0; i < msgs.length; i++){
               msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
               Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
               myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               myIntent.putExtra("address", msgs[i].getOriginatingAddress());
               myIntent.setType("vnd.android-dir/mms-sms");
               context.startActivity(myIntent);
               
            }
         }
         
   }

}
grimx
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Dec 05, 2009 12:47 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests