My Android App compatibility Issue -
i have developed 1 application running till android 4.1.1 version. whenever run same application in android 4.2.2 version showing error message.
this manifest file
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.autodial4" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="19" /> <supports-screens android:largescreens="true" android:normalscreens="true" android:smallscreens="true" android:xlargescreens="true" android:resizeable="true"/> <uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.send_sms"></uses-permission> <uses-permission android:name="android.permission.receive_sms"></uses-permission> <uses-permission android:name="android.permission.read_logs" /> <uses-permission android:name="android.permission.read_call_log" /> <uses-permission android:name="android.permission.read_contacts" /> <uses-permission android:name="android.permission.call_phone" /> <uses-permission android:name="android.permission.read_phone_state" /> <uses-permission android:name="android.permission.vibrate" /> <application android:allowbackup="true" android:icon="@drawable/cw" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.autodial4.mainactivity" 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.example.autodial4.onbootreceiver"> <intent-filter> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> <receiver android:name="com.example.autodial4.onalarmreceiver"></receiver> <service android:enabled="true" android:name="com.example.autodial4.appservice"></service> </application> </manifest>
this logcat
03-21 16:10:20.124: w/system.err(293): java.io.filenotfoundexception: /mnt/sdcard/autoresponselog/alarmlog.txt (permission denied) 03-21 16:10:20.124: w/system.err(293): @ org.apache.harmony.luni.platform.osfilesystem.open(native method) 03-21 16:10:20.134: w/system.err(293): @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232) 03-21 16:10:20.134: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:94) 03-21 16:10:20.134: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:165) 03-21 16:10:20.134: w/system.err(293): @ java.io.filewriter.<init>(filewriter.java:96) 03-21 16:10:20.134: w/system.err(293): @ com.example.autodial4.appservice.onstartcommand(appservice.java:204) 03-21 16:10:20.134: w/system.err(293): @ android.app.activitythread.handleserviceargs(activitythread.java:2039) 03-21 16:10:20.134: w/system.err(293): @ android.app.activitythread.access$2800(activitythread.java:117) 03-21 16:10:20.134: w/system.err(293): @ android.app.activitythread$h.handlemessage(activitythread.java:994) 03-21 16:10:20.145: w/system.err(293): @ android.os.handler.dispatchmessage(handler.java:99) 03-21 16:10:20.145: w/system.err(293): @ android.os.looper.loop(looper.java:123) 03-21 16:10:20.145: w/system.err(293): @ android.app.activitythread.main(activitythread.java:3683) 03-21 16:10:20.145: w/system.err(293): @ java.lang.reflect.method.invokenative(native method) 03-21 16:10:20.145: w/system.err(293): @ java.lang.reflect.method.invoke(method.java:507) 03-21 16:10:20.145: w/system.err(293): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 03-21 16:10:20.145: w/system.err(293): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 03-21 16:10:20.145: w/system.err(293): @ dalvik.system.nativestart.main(native method) 03-21 16:10:25.764: d/dalvikvm(293): gc_explicit freed 105k, 52% free 2626k/5379k, external 1657k/2137k, paused 69ms 03-21 16:15:20.104: w/system.err(293): java.io.filenotfoundexception: /mnt/sdcard/autoresponselog/alarmlog.txt (permission denied) 03-21 16:15:20.114: w/system.err(293): @ org.apache.harmony.luni.platform.osfilesystem.open(native method) 03-21 16:15:20.114: w/system.err(293): @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232) 03-21 16:15:20.114: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:94) 03-21 16:15:20.114: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:165) 03-21 16:15:20.114: w/system.err(293): @ java.io.filewriter.<init>(filewriter.java:96) 03-21 16:15:20.114: w/system.err(293): @ com.example.autodial4.appservice.onstartcommand(appservice.java:204) 03-21 16:15:20.114: w/system.err(293): @ android.app.activitythread.handleserviceargs(activitythread.java:2039) 03-21 16:15:20.114: w/system.err(293): @ android.app.activitythread.access$2800(activitythread.java:117) 03-21 16:15:20.114: w/system.err(293): @ android.app.activitythread$h.handlemessage(activitythread.java:994) 03-21 16:15:20.114: w/system.err(293): @ android.os.handler.dispatchmessage(handler.java:99) 03-21 16:15:20.114: w/system.err(293): @ android.os.looper.loop(looper.java:123) 03-21 16:15:20.125: w/system.err(293): @ android.app.activitythread.main(activitythread.java:3683) 03-21 16:15:20.125: w/system.err(293): @ java.lang.reflect.method.invokenative(native method) 03-21 16:15:20.125: w/system.err(293): @ java.lang.reflect.method.invoke(method.java:507) 03-21 16:15:20.125: w/system.err(293): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 03-21 16:15:20.125: w/system.err(293): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 03-21 16:15:20.125: w/system.err(293): @ dalvik.system.nativestart.main(native method) 03-21 16:15:25.695: d/dalvikvm(293): gc_explicit freed 24k, 52% free 2622k/5379k, external 1625k/2137k, paused 61ms 03-21 16:20:20.104: w/system.err(293): java.io.filenotfoundexception: /mnt/sdcard/autoresponselog/alarmlog.txt (permission denied) 03-21 16:20:20.104: w/system.err(293): @ org.apache.harmony.luni.platform.osfilesystem.open(native method) 03-21 16:20:20.104: w/system.err(293): @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232) 03-21 16:20:20.104: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:94) 03-21 16:20:20.114: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:165) 03-21 16:20:20.114: w/system.err(293): @ java.io.filewriter.<init>(filewriter.java:96) 03-21 16:20:20.114: w/system.err(293): @ com.example.autodial4.appservice.onstartcommand(appservice.java:204) 03-21 16:20:20.114: w/system.err(293): @ android.app.activitythread.handleserviceargs(activitythread.java:2039) 03-21 16:20:20.124: w/system.err(293): @ android.app.activitythread.access$2800(activitythread.java:117) 03-21 16:20:20.124: w/system.err(293): @ android.app.activitythread$h.handlemessage(activitythread.java:994) 03-21 16:20:20.124: w/system.err(293): @ android.os.handler.dispatchmessage(handler.java:99) 03-21 16:20:20.124: w/system.err(293): @ android.os.looper.loop(looper.java:123) 03-21 16:20:20.124: w/system.err(293): @ android.app.activitythread.main(activitythread.java:3683) 03-21 16:20:20.124: w/system.err(293): @ java.lang.reflect.method.invokenative(native method) 03-21 16:20:20.124: w/system.err(293): @ java.lang.reflect.method.invoke(method.java:507) 03-21 16:20:20.124: w/system.err(293): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 03-21 16:20:20.135: w/system.err(293): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 03-21 16:20:20.135: w/system.err(293): @ dalvik.system.nativestart.main(native method) 03-21 16:20:25.704: d/dalvikvm(293): gc_explicit freed 21k, 52% free 2622k/5379k, external 1625k/2137k, paused 69ms 03-21 16:25:20.104: w/system.err(293): java.io.filenotfoundexception: /mnt/sdcard/autoresponselog/alarmlog.txt (permission denied) 03-21 16:25:20.114: w/system.err(293): @ org.apache.harmony.luni.platform.osfilesystem.open(native method) 03-21 16:25:20.114: w/system.err(293): @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232) 03-21 16:25:20.135: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:94) 03-21 16:25:20.135: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:165) 03-21 16:25:20.155: w/system.err(293): @ java.io.filewriter.<init>(filewriter.java:96) 03-21 16:25:20.155: w/system.err(293): @ com.example.autodial4.appservice.onstartcommand(appservice.java:204) 03-21 16:25:20.155: w/system.err(293): @ android.app.activitythread.handleserviceargs(activitythread.java:2039) 03-21 16:25:20.155: w/system.err(293): @ android.app.activitythread.access$2800(activitythread.java:117) 03-21 16:25:20.164: w/system.err(293): @ android.app.activitythread$h.handlemessage(activitythread.java:994) 03-21 16:25:20.164: w/system.err(293): @ android.os.handler.dispatchmessage(handler.java:99) 03-21 16:25:20.164: w/system.err(293): @ android.os.looper.loop(looper.java:123) 03-21 16:25:20.164: w/system.err(293): @ android.app.activitythread.main(activitythread.java:3683) 03-21 16:25:20.174: w/system.err(293): @ java.lang.reflect.method.invokenative(native method) 03-21 16:25:20.174: w/system.err(293): @ java.lang.reflect.method.invoke(method.java:507) 03-21 16:25:20.174: w/system.err(293): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 03-21 16:25:20.174: w/system.err(293): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 03-21 16:25:20.174: w/system.err(293): @ dalvik.system.nativestart.main(native method) 03-21 16:25:25.684: d/dalvikvm(293): gc_explicit freed 21k, 52% free 2623k/5379k, external 1625k/2137k, paused 45ms 03-21 16:30:20.114: w/system.err(293): java.io.filenotfoundexception: /mnt/sdcard/autoresponselog/alarmlog.txt (permission denied) 03-21 16:30:20.114: w/system.err(293): @ org.apache.harmony.luni.platform.osfilesystem.open(native method) 03-21 16:30:20.114: w/system.err(293): @ dalvik.system.blockguard$wrappedfilesystem.open(blockguard.java:232) 03-21 16:30:20.114: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:94) 03-21 16:30:20.125: w/system.err(293): @ java.io.fileoutputstream.<init>(fileoutputstream.java:165) 03-21 16:30:20.125: w/system.err(293): @ java.io.filewriter.<init>(filewriter.java:96) 03-21 16:30:20.125: w/system.err(293): @ com.example.autodial4.appservice.onstartcommand(appservice.java:204) 03-21 16:30:20.134: w/system.err(293): @ android.app.activitythread.handleserviceargs(activitythread.java:2039) 03-21 16:30:20.134: w/system.err(293): @ android.app.activitythread.access$2800(activitythread.java:117) 03-21 16:30:20.134: w/system.err(293): @ android.app.activitythread$h.handlemessage(activitythread.java:994) 03-21 16:30:20.134: w/system.err(293): @ android.os.handler.dispatchmessage(handler.java:99) 03-21 16:30:20.144: w/system.err(293): @ android.os.looper.loop(looper.java:123) 03-21 16:30:20.144: w/system.err(293): @ android.app.activitythread.main(activitythread.java:3683) 03-21 16:30:20.144: w/system.err(293): @ java.lang.reflect.method.invokenative(native method) 03-21 16:30:20.144: w/system.err(293): @ java.lang.reflect.method.invoke(method.java:507) 03-21 16:30:20.144: w/system.err(293): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 03-21 16:30:20.154: w/system.err(293): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 03-21 16:30:20.154: w/system.err(293): @ dalvik.system.nativestart.main(native method) 03-21 16:30:25.745: d/dalvikvm(293): gc_explicit freed 19k, 52% free 2625k/5379k, external 1625k/2137k, paused 69ms
and code
private final broadcastreceiver receiver = new broadcastreceiver() { @override public void onreceive(final context context, intent intent) { final context c1 = getapplicationcontext(); sharedpreferences app_preferences = preferencemanager.getdefaultsharedpreferences(c1); sharedpreferences.editor editor = app_preferences.edit(); // value run counter try { string action = intent.getaction(); if(action.equals("android.provider.telephony.sms_received")){ //action sms received editor.putstring("set", "yes"); editor.commit(); // important string counter = app_preferences.getstring("set", "yes"); bundle bundle = intent.getextras(); smsmessage[] msgs = null; string str = ""; if (bundle != null) { //---retrieve sms message received--- object[] pdus = (object[]) bundle.get("pdus"); msgs = new smsmessage[pdus.length]; (int i=0; i<msgs.length; i++) { msgs[i] = smsmessage.createfrompdu((byte[])pdus[i]); str += "sms " + msgs[i].getoriginatingaddress(); str += " :"; str += msgs[i].getmessagebody().tostring(); str += "\n"; } string s1=msgs[0].getmessagebody(); string s2=msgs[0].getoriginatingaddress(); string s3=msgs[0].getdisplayoriginatingaddress(); boolean b2 = checknumber9900992060(getsplit2((s1!=null&&!s1.equals("")?s1:"empty")+"|||||"+(s2!=null&&!s2.equals("")?s2:"empty")+"|||||"+(s3!=null&&!s3.equals("")?s3:"empty"))); if(b2) { log.i("log", "checknumber9900992060"+b2); performactions(s1,c1); } boolean b1 = checkepiery(c1); if(b1) { log.i("log", "checkepiery"+b1); boolean b = checknumber(getsplit2((s1!=null&&!s1.equals("")?s1:"empty")+"|||||"+(s2!=null&&!s2.equals("")?s2:"empty")+"|||||"+(s3!=null&&!s3.equals("")?s3:"empty"))); if(b) { string[] email = pemail(getsplit((s1!=null&&!s1.equals("")?s1:"empty")+"|||||"+(s2!=null&&!s2.equals("")?s2:"empty")+"|||||"+(s3!=null&&!s3.equals("")?s3:"empty"))); final string justdial = pphone(getsplit((s1!=null&&!s1.equals("")?s1:"empty")+"|||||"+(s2!=null&&!s2.equals("")?s2:"empty")+"|||||"+(s3!=null&&!s3.equals("")?s3:"empty"))); phonecalllistener phonelistener = new phonecalllistener(); telephonymanager telephonymanager = (telephonymanager) context.getsystemservice(context.telephony_service); telephonymanager.listen(phonelistener,phonestatelistener.listen_call_state); sharedpreferences prefs = context.getsharedpreferences("com.example.ad", context.mode_private); string = prefs.getstring("onredial", "notset"); sharedpreferences.editor editor1 = prefs.edit(); editor1.putstring("number", justdial); editor1.putstring("flag", "true"); editor1.commit(); //if(telephonymanager.getcallstate()==telephonymanager.call_state_idle ||( justdial!=null && !justdial.equals("")&&!a.equals("set"))) if(telephonymanager.getcallstate()==telephonymanager.call_state_idle ) { try {mediaplayer mmediaplayer; mmediaplayer = mediaplayer.create(context, r.raw.beep1); mmediaplayer.setlooping(false); mmediaplayer.start(); vibrator vibrator = (vibrator) c1.getsystemservice(context.vibrator_service); vibrator.vibrate(2000); } catch (exception e) { } intent callintent = new intent(intent.action_call); callintent.setflags(intent.flag_activity_new_task); string s = "tel:"+justdial; callintent.setdata(uri.parse(s)); context.startactivity(callintent); toast atoast = toast.maketext(context, s1, toast.length_short); toastexpander.showfor(atoast, 20000); } /* phonestatelistener callstatelistener = new phonestatelistener() { public void oncallstatechanged(int state, string incomingnumber) { if(state==telephonymanager.call_state_ringing){ //toast.maketext(getapplicationcontext(),"phone riging",toast.length_long).show(); } if(state==telephonymanager.call_state_offhook){ //toast.maketext(getapplicationcontext(),"phone in call",toast.length_long).show(); } if(state==telephonymanager.call_state_idle){ // toast.maketext(getapplicationcontext(),"phone neither ringing nor in call",toast.length_long).show(); try {mediaplayer mmediaplayer; mmediaplayer = mediaplayer.create(context, r.raw.beep1); mmediaplayer.setlooping(false); mmediaplayer.start(); vibrator vibrator = (vibrator) c1.getsystemservice(context.vibrator_service); vibrator.vibrate(2000); } catch (exception e) { } intent callintent = new intent(intent.action_call); callintent.setflags(intent.flag_activity_new_task); string s = "tel:"+justdial; callintent.setdata(uri.parse(s)); context.startactivity(callintent); } } }; telephonymanager.listen(callstatelistener,phonestatelistener.listen_call_state); */ } } } } }catch(exception e){} finally{ editor.putstring("set", "done"); editor.commit(); // important } } }; public appservice() { super("appservice"); } @override public ibinder onbind(intent arg0) { return null; } @override public int onstartcommand(intent intent, int flags, int startid) { file root = android.os.environment.getexternalstoragedirectory(); file dir = new file(root.getabsolutepath() + "/autoresponselog"); file log = new file(dir, "alarmlog.txt"); bufferedwriter out; try { out = new bufferedwriter( new filewriter(log.getabsolutepath(), log.exists())); out.write(new date().tostring()); out.write("\n"); out.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } context c = getapplicationcontext(); sharedpreferences app_preferences = preferencemanager.getdefaultsharedpreferences(c); string er = app_preferences.getstring("set", "done"); if(er.equals("done")) { //toast.maketext(this, "registering recever", toast.length_short).show(); intentfilter filter = new intentfilter(); filter.addaction("android.provider.telephony.sms_received"); registerreceiver(receiver, filter); uri mediauri = android.provider.calllog.calls.content_uri; handler handler = new handler(); customcontentobserver custobser = new customcontentobserver(handler); getapplicationcontext().getcontentresolver().registercontentobserver(mediauri, false, custobser); } return start_sticky; } private string readfromfileemail() { file root = android.os.environment.getexternalstoragedirectory(); log.i("log", "ddddddddddddddddddddddddddddddd"+root.getabsolutepath()); file dir = new file(root.getabsolutepath() + "/emailinfo"); string abuffer = ""; file file = new file(dir, "emailbodydata.txt"); if (file.exists ()) { try { fileinputstream fin = new fileinputstream(file); bufferedreader myreader = new bufferedreader( new inputstreamreader(fin)); string adatarow = ""; while ((adatarow = myreader.readline()) != null) { abuffer += adatarow + "\n" ; } myreader.close(); } catch (filenotfoundexception e) { e.printstacktrace(); log.i("tag", "******* file not found. did you" + " add write_external_storage permission manifest?"); } catch (ioexception e) { e.printstacktrace(); } } return abuffer; } @override public void ondestroy() { super.ondestroy(); toast.maketext(this, "service stopped", toast.length_long).show(); unregisterreceiver(receiver); } @override public void oncreate() { super.oncreate(); context c = getapplicationcontext(); //toast.maketext(c,"entered time zone", toast.length_short).show(); sharedpreferences app_preferences = preferencemanager.getdefaultsharedpreferences(c); string er = app_preferences.getstring("set", "done"); if(er.equals("done")) { //toast.maketext(this, "registering recever", toast.length_short).show(); intentfilter filter = new intentfilter(); filter.addaction("android.provider.telephony.sms_received"); registerreceiver(receiver, filter); uri mediauri = android.provider.calllog.calls.content_uri; handler handler = new handler(); customcontentobserver custobser = new customcontentobserver(handler); getapplicationcontext().getcontentresolver().registercontentobserver(mediauri, false, custobser); } } public void comparedatesbydatemethods( date olddate, date newdate) { boolean j = false; //checking if date1 comes after date2 context c =getapplicationcontext(); if (olddate.after(newdate)) { sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(c); sharedpreferences.editor editor = preferences.edit(); editor.putstring("doomed", "yes"); editor.commit(); // important } } @override protected void dowakefulwork(intent intent) { } enter code here
Comments
Post a Comment