android - my sms receiver can't accept new sms -


i want receive sms on application, when try new sms application didn't new sms. cannot find doing wrong. i'm not sure if there's wrong code, or debugging.

i'm trying notified if new sms arrives , save sms on database.

this receiver.

public void onreceive( context c, intent i) {     bundle b = i.getextras();     smsmessage[] m = null;     string s = "";     telephonymanager teleponymanager = (telephonymanager) c.getsystemservice(context.telephony_service);     int x;     if (b != null) { //if valid sms         object[] p = (object[]) b.get("p");         m = new smsmessage[p.length];         (x = 0; x < m.length; x++) { //for ambil konten sms             m[x] = smsmessage.createfrompdu((byte[])p[x]);             s += "sms dari " +m[x].getoriginatingaddress().tostring().trim();             s += " :";             s += m[x].getmessagebody().tostring();             s += "\n";                                       }         toast.maketext(c, s, toast.length_long).show();          nomor = m[x].getoriginatingaddress().tostring().trim();         pesan = m[x].getmessagebody().tostring();          cursor cursorkontak = data.pilihkontak(nomor);         if(cursorkontak.movetofirst()) {             idkontak = cursorkontak.getstring(cursorkontak.getcolumnindex("idkontak"));         }          if(idkontak == null) {             nama = nomor;             data.inputkontak(nama, nomor);              cursor cursorkontak2 = data.pilihkontak(nomor);             if(cursorkontak2.movetofirst()) {                 idkontak = cursorkontak2.getstring(cursorkontak2.getcolumnindex("idkontak"));             }              data.inputpesanmasuk(idkontak, pesan);                }else {             data.inputpesanmasuk(idkontak, pesan);         }          intent broadcastintent = new intent();         broadcastintent.setaction("sms_received_action");         broadcastintent.putextra("sms", s);         c.sendbroadcast(broadcastintent); 

my android manifest

update

<?xml version="1.0" encoding="utf-8"?> <manifest android:versioncode="1" android:versionname="1.0" package="com.sms" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-sdk android:minsdkversion="10"/> <uses-permission android:name="android.permission.read_contacts"/> <uses-permission android:name="android.permission.send_sms"/> <uses-permission android:name="android.permission.read_sms"/> <uses-permission android:name="android.permission.receive_sms"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">     <activity android:label="@string/app_name"         android:name="enkripsisms" android:screenorientation="portrait">         <intent-filter>             <action android:name="android.intent.action.main"/>             <category android:name="android.intent.category.launcher"/>         </intent-filter>       </activity>         <receiver android:name=".smsreceiver" >             <intent-filter >                 <action android:name="android.provider.telephony.sms_received"/>             </intent-filter>         </receiver>      <activity android:name=".kotakmasuk"/>     <activity android:name=".tulispesan"/>     <activity android:name=".kotakkeluar"/>     <activity android:name=".hasilenkripsi"/>     <activity android:name=".kirimpesan"/>     <activity android:name=".isipesankeluar"/>     <activity android:name=".dekripsipesankeluar"/>     <activity android:name=".hasildekripsipesankeluar"/>     <activity android:name=".teruskanpesankeluar"/>     <activity android:name=".kirimpesankeluar"/>     <activity android:name=".isipesanmasuk"/>     <activity android:name=".dekripsipesanmasuk"/>     <activity android:name=".teruskanpesanmasuk"/>     <activity android:name=".hasildekripsipesanmasuk"/>     <activity android:name=".balas"/>     <activity android:name=".hasilbalas"/>     <activity android:name=".kirimpesanmasuk"/> </application> </manifest> 

can me? need solution. thanks..

instead of p use pdus

object[] p = (object[]) b.get("pdus"); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -