java - Android internet permission missing -
i've added internet permission in androidmanifest.xml, still internet permission missing error thrown.
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="info.androidhive.slidingmenu" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.internet"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="info.androidhive.slidingmenu.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> </application> </manifest>
i'm following example how make rss reader: https://www.androidpit.com/java-guide-2-program-your-own-rss-reader
i've done giving internet permission, after add internet permissions, still error stating internet permissions missing.
homefragment.java
import android.app.fragment; import android.os.asynctask; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.textview; import java.io.bytearrayoutputstream; import java.io.ioexception; import java.io.inputstream; import java.net.httpurlconnection; import java.net.url; public class homefragment extends fragment { private textview mrssfeed; public homefragment(){} @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_home, container, false); mrssfeed = (textview) rootview.findviewbyid(r.id.rss_feed); return rootview; } @override public void onstart() { super.onstart(); new getandroidpitrssfeedtask().execute(); } private string getandroidpitrssfeed() throws ioexception { inputstream in = null; string rssfeed = null; try { url url = new url("http://www.androidpit.com/feed/main.xml"); httpurlconnection conn = (httpurlconnection) url.openconnection(); in = conn.getinputstream(); bytearrayoutputstream out = new bytearrayoutputstream(); byte[] buffer = new byte[1024]; (int count; (count = in.read(buffer)) != -1; ) { out.write(buffer, 0, count); } byte[] response = out.tobytearray(); rssfeed = new string(response, "utf-8"); } { if (in != null) { in.close(); } } return rssfeed; } private class getandroidpitrssfeedtask extends asynctask<void, void, string> { @override protected string doinbackground(void... voids) { string result = ""; try { result = getandroidpitrssfeed(); } catch (ioexception e) { e.printstacktrace(); } return result; } @override protected void onpostexecute(string rssfeed) { mrssfeed.settext(rssfeed); } } }
log error message
04-19 09:01:45.882 8172-8196/info.androidhive.slidingmenu e/androidruntime: fatal exception: asynctask #1 process: info.androidhive.slidingmenu, pid: 8172 java.lang.runtimeexception: error occurred while executing doinbackground() @ android.os.asynctask$3.done(asynctask.java:309) @ java.util.concurrent.futuretask.finishcompletion(futuretask.java:354) @ java.util.concurrent.futuretask.setexception(futuretask.java:223) @ java.util.concurrent.futuretask.run(futuretask.java:242) @ android.os.asynctask$serialexecutor$1.run(asynctask.java:234) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1113) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:588) @ java.lang.thread.run(thread.java:818) caused by: java.lang.securityexception: permission denied (missing internet permission?) @ java.net.inetaddress.lookuphostbyname(inetaddress.java:464) @ java.net.inetaddress.getallbynameimpl(inetaddress.java:252) @ java.net.inetaddress.getallbyname(inetaddress.java:215) @ com.android.okhttp.internal.network$1.resolveinetaddresses(network.java:29) @ com.android.okhttp.internal.http.routeselector.resetnextinetsocketaddress(routeselector.java:188) @ com.android.okhttp.internal.http.routeselector.nextproxy(routeselector.java:157) @ com.android.okhttp.internal.http.routeselector.next(routeselector.java:100) @ com.android.okhttp.internal.http.httpengine.createnextconnection(httpengine.java:357) @ com.android.okhttp.internal.http.httpengine.nextconnection(httpengine.java:340) @ com.android.okhttp.internal.http.httpengine.connect(httpengine.java:330) @ com.android.okhttp.internal.http.httpengine.sendrequest(httpengine.java:248) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.execute(httpurlconnectionimpl.java:437) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:388) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:231) @ info.androidhive.slidingmenu.homefragment.getandroidpitrssfeed(homefragment.java:44) @ info.androidhive.slidingmenu.homefragment.access$100(homefragment.java:17) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:66) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:60) @ android.os.asynctask$2.call(asynctask.java:295) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.asynctask$serialexecutor$1.run(asynctask.java:234) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1113) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:588) @ java.lang.thread.run(thread.java:818) caused by: android.system.gaiexception: android_getaddrinfo failed: eai_nodata (no address associated hostname) @ libcore.io.posix.android_getaddrinfo(native method) @ libcore.io.forwardingos.android_getaddrinfo(forwardingos.java:55) @ java.net.inetaddress.lookuphostbyname(inetaddress.java:451) @ java.net.inetaddress.getallbynameimpl(inetaddress.java:252) @ java.net.inetaddress.getallbyname(inetaddress.java:215) @ com.android.okhttp.internal.network$1.resolveinetaddresses(network.java:29) @ com.android.okhttp.internal.http.routeselector.resetnextinetsocketaddress(routeselector.java:188) @ com.android.okhttp.internal.http.routeselector.nextproxy(routeselector.java:157) @ com.android.okhttp.internal.http.routeselector.next(routeselector.java:100) @ com.android.okhttp.internal.http.httpengine.createnextconnection(httpengine.java:357) @ com.android.okhttp.internal.http.httpengine.nextconnection(httpengine.java:340) @ com.android.okhttp.internal.http.httpengine.connect(httpengine.java:330) @ com.android.okhttp.internal.http.httpengine.sendrequest(httpengine.java:248) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.execute(httpurlconnectionimpl.java:437) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:388) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:231) @ info.androidhive.slidingmenu.homefragment.getandroidpitrssfeed(homefragment.java:44) @ info.androidhive.slidingmenu.homefragment.access$100(homefragment.java:17) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:66) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:60) @ android.os.asynctask$2.call(asynctask.java:295) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.asynctask$serialexecutor$1.run(asynctask.java:234) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1113) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:588) @ java.lang.thread.run(thread.java:818) caused by: android.system.errnoexception: android_getaddrinfo failed: eacces (permission denied) @ libcore.io.posix.android_getaddrinfo(native method) @ libcore.io.forwardingos.android_getaddrinfo(forwardingos.java:55) @ java.net.inetaddress.lookuphostbyname(inetaddress.java:451) @ java.net.inetaddress.getallbynameimpl(inetaddress.java:252) @ java.net.inetaddress.getallbyname(inetaddress.java:215) @ com.android.okhttp.internal.network$1.resolveinetaddresses(network.java:29) @ com.android.okhttp.internal.http.routeselector.resetnextinetsocketaddress(routeselector.java:188) @ com.android.okhttp.internal.http.routeselector.nextproxy(routeselector.java:157) @ com.android.okhttp.internal.http.routeselector.next(routeselector.java:100) @ com.android.okhttp.internal.http.httpengine.createnextconnection(httpengine.java:357) @ com.android.okhttp.internal.http.httpengine.nextconnection(httpengine.java:340) @ com.android.okhttp.internal.http.httpengine.connect(httpengine.java:330) @ com.android.okhttp.internal.http.httpengine.sendrequest(httpengine.java:248) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.execute(httpurlconnectionimpl.java:437) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:388) @ com.android.okhttp.internal.huc.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:231) @ info.androidhive.slidingmenu.homefragment.getandroidpitrssfeed(homefragment.java:44) @ info.androidhive.slidingmenu.homefragment.access$100(homefragment.java:17) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:66) @ info.androidhive.slidingmenu.homefragment$getandroidpitrssfeedtask.doinbackground(homefragment.java:60) @ android.os.asynctask$2.call(asynctask.java:295) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.asynctask$serialexecutor$1.run(asynctask.java:234) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1113) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:588) @ java.lang.thread.run(thread.java:818)
you have define both permissions
<uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.internet" />
and clean & rebuild project..
Comments
Post a Comment