开发者

Android Problem after adding INTERNET Permission

开发者 https://www.devze.com 2023-03-10 03:04 出处:网络
Trying to do a simple httpget on a JSON object but I\'m having trouble adding the INTERNET permission.

Trying to do a simple httpget on a JSON object but I'm having trouble adding the INTERNET permission.

When I add "" OUTSIDE of the application tags in the manifest I get a blank (black) screen when I run the program and none of my toast messages pop up or anything.

When added INSIDE the application tags I cannot connect!

As of now I have just the default main layout with one button added.

Does it make a difference that my http code is in another file as a simple java class?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.ai"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />




    <application android:icon="@drawab开发者_JAVA技巧le/icon" android:label="@string/app_name">

        <activity android:name=".ShowList"
                  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>

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>"


</manifest>


  1. This is the right way of adding the permission. Your messages may not popup for a completely different reason, not a permission problem.

  2. No, it does not matter, as long as the code is executed as part of the activity.

I suggest you to read the logcat and look for any warning message. Also, add logs so you can track whether you are connecting or not, and if so, what the response is.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.ai"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <uses-permission android:name="android.permission.INTERNET"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ShowList"
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>   

</manifest>

Uses permission statement have to be used like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消