Reputation: 2163
I'm trying to make a preference screen for my android application, but I'm failing completely. I'm following this guide. When I try to install the application, I get this error message, and it won't install the app on my phone:
[2012-04-10 12:54:45 - AndroidCurrencyConverter] ------------------------------
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Android Launch!
[2012-04-10 12:54:45 - AndroidCurrencyConverter] adb is running normally.
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Performing ValutaConverter.namespace.AndroidValutaConverterActivity activity launch
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Automatic Target Mode: using device '3134BC2BBCA800EC'
[2012-04-10 12:54:45 - AndroidCurrencyConverter] Uploading AndroidCurrencyConverter.apk onto device '3134BC2BBCA800EC'
[2012-04-10 12:54:46 - AndroidCurrencyConverter] Installing AndroidCurrencyConverter.apk...
[2012-04-10 12:54:49 - AndroidCurrencyConverter] Success!
[2012-04-10 12:54:49 - AndroidCurrencyConverter] Starting activity ValutaConverter.namespace.AndroidValutaConverterActivity on device 3134BC2BBCA800EC
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=ValutaConverter.namespace/.AndroidValutaConverterActivity }
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=ValutaConverter.namespace/.AndroidValutaConverterActivity } from null (pid=11486, uid=2000) requires android.permission.INTERNET
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.os.Parcel.readException(Parcel.java:1327)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.os.Parcel.readException(Parcel.java:1281)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1631)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.runStart(Am.java:433)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.run(Am.java:107)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.commands.am.Am.main(Am.java:80)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.internal.os.RuntimeInit.finishInit(Native Method)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:238)
[2012-04-10 12:54:52 - AndroidCurrencyConverter] ActivityManager: at dalvik.system.NativeStart.main(Native Method)
What I understood from this code was that when it tries to start the Intent, it fails because it requires android.permission.INTERNET. But this is already defined in my manifest file.
I had the app working at some point, but I added a few things to my activity, added another activity, and some XML files. After this, it won't install the app on the phone. What I added was:
In the activity class:
addPreferencesFromResource(R.xml.preferences);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, 0, 0, "Show current settings");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
startActivity(new Intent(this, ShowSettingsActivity.class));
return true;
}
return false;
}
If you need any other information about the code or the likes of that, I will gladly post some of it.
Help!
Upvotes: 0
Views: 470
Reputation: 897
Two things to check.
Your activity is extending PreferenceActivity, and
That your layout has a default ListView with the id android:list
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Also you may want to think about implementing OnSharedPreferenceChangeListener in your activity if you need to handle preference changes.
Upvotes: 0
Reputation: 109257
It should be,
<uses-permission
android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:name=".AndroidValutaConverterActivity"
android:theme="@android:style/Theme.DeviceDefault" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ShowSettingsActivity"/>
</application>
remove it from activity tag in your manifest file.
Upvotes: 2
Reputation: 27004
Indeed, but your are not allowing the INTERNET permission in the manifest (instead, you explictely say that the activity requires the INTERNET permission).
You should have a <permission>
element at the root of the manifest, as explained in the doc.
Upvotes: 1