android - Broadcast receiver works in emulator but not in phone -
i'm working on app when enabled reject incoming calls predefined sms. app works fine in emulator. tested 2 emulators. when call 1 another, works seamlessly declining call , sending sms incoming no. received sms on other emulator. have strange problem here. when install app in mobile, not working. tried 2 mobiles android(2.3.3 & 4.0.3) still no luck.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.praveenkutti1990.ezmesseger" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="10" /> <uses-permission android:name="android.permission.call_phone"/> <uses-permission android:name="android.permission.read_phone_state"/> <uses-permission android:name="android.permission.send_sms"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.praveenkutti1990.ezmesseger.ezmessger" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <receiver android:name="com.praveenkutti1990.ezmesseger.receiver" android:label="@string/app_name" android:enabled="false"> <intent-filter android:priority="999"> <action android:name="android.intent.action.phone_state" /> </intent-filter> </receiver> </application> </manifest>
and broadcastreceiver is
public void onreceive(context context, intent intent) { // todo auto-generated method stub string s[]={"9000000000","15555215556","15555215554"}; bundle b = intent.getextras(); incomingnumber = b.getstring(telephonymanager.extra_incoming_number); try { telephonymanager tm = (telephonymanager) context.getsystemservice(context.telephony_service); class c = class.forname(tm.getclass().getname()); method m = c.getdeclaredmethod("getitelephony"); m.setaccessible(true); com.android.internal.telephony.itelephony telephonyservice = (itelephony) m.invoke(tm); (int = 0; < s.length; i++) { if(s[i].equals(incomingnumber)){ telephonyservice.endcall(); } }
i added option enable/disable receiver in activity. intention block specific numbers sms. looks , works fine in emulator. not in mobile. can't find i'm wrong?
Comments
Post a Comment