I`m trying to understand, how permissions work in android. I made simple project: 1 source file and 1 xml-layout. And:
1) I define permission to activity (activity name is "AndroidTestActivity", permission name is "android.permission.MY_PERMISSION"),
2) I define uses-permission for activity (),
My problem is: when I run AndroidTestActivity, logcat says:
08-19 19:39:18.311: WARN/ActivityManager(59): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.Android.Test/.AndroidTestActivity } from null (pid=-1, uid=-1) requires android.permission.MY_PERMISSION
Why do I get Permission Denial? I made uses-permission, isn`t it enough?
Here is AndroidManifest source:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Android.Test" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<permission android:name="android.permission.MY_PERMISSION" android:protectionLevel="normal"></permission>
<uses-permission android:name="android.permission.MY_PERMISSION"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".AndroidTestActivity" android:permission="android.permission.MY_PERMISSION"
android:label="Sample menus application">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is AndroidTestActivity source:
public class AndroidTestActivity extends Activity {
TextView tv;
Menu myMenu=null;
#Override
public void onCreate(Bundle savedlnstanceState) {
super.onCreate(savedlnstanceState);
setContentView(R.layout.main);
}
}
According to the docs it should smth like this:
<permission android:name="com.example.Android.Test.permission.MY_PERMISSION"
android:protectionLevel="normal"
android:description="Some description"
android:label="Some label" />
<uses-permission
android:name="com.example.Android.Test.permission.MY_PERMISSION" />
Related
I am successfully calling my first Activity from my AIR Native Extension, however, when I try to call the second one, I am getting the Permission Denial error (see logcat screenshot). I have tried everything I have found suggested on this site, so posting question.
02-12 15:43:22.430: I/ActivityManager(271): START {act=android.intent.action.RUN cmp=com.cno.android.map/.AddMarkerActivity (has extras) u=0} from pid 14173
02-12 15:43:22.440: W/ActivityManager(271): Permission Denial: starting Intent { act=android.intent.action.RUN cmp=com.cno.android.map/.AddMarkerActivity (has extras) } from ProcessRecord{4147a718 14173:air.TestAndroidExtension.debug/u0a75} (pid=14173, uid=10075) not exported from uid 10072
Here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cno.android.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- End of copy. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<activity
android:name="com.cno.android.map.InitMapActivity"
android:label="#string/title_activity_init_map" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.cno.android.map.AddMarkerActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RUN"/>
</intent-filter>
</activity>
</application>
Things to note:
I first tried AddMarkerActivity without any intent-filter defined. Not having ANY luck, I began experimenting with the RUN action. I have commented everything out in AddMarkerActivity except for one logcat message that says "HELLO" in the onCreate method. As you can see my Activity is not duplicated in the manifest and exported is set to true.
And finally, here is how I am calling the Activity:
public class AddAnnotationFunction implements FREFunction {
public static final String TAG = "AddAnnotationFunction";
public final static String EXTRA_MARKER = "com.cno.nativemap.functions.marker";
#Override
public FREObject call(FREContext context, FREObject[] args) {
Intent intent = new Intent();
intent.setClassName("com.cno.android.map", "com.cno.android.map.AddMarkerActivity");
Log.d(TAG, "Starting Map Activity- add marker");
intent.setAction("android.intent.action.RUN");
intent.putExtra(EXTRA_MARKER, new GeoMarker(args));
context.getActivity().startActivity(intent);
return null;
}
}
This is the error that shows on my logcat when i run my TagViewer.java for NFC on Eclipse. I am running a NFC program and basically it runs however at a certain period of time the program shuts down on its own.
08-29 14:06:33.677: E/ViewTag(22056): Unknown intent Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.android.nfc/.TagViewer }
This is from my Android Manifest. I am guessing that the error is from here because of the line on the error android.intent.action.MAIN and such.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.nfc"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="16" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".TagViewer"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
this is from my java and basically the last line, when i put // the program will not shut down but it will show like a white page.However the title NFC is still showing so i know that it is slightly working
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTagContent = (LinearLayout) findViewById(R.id.tag_viewer);
mTitle = (TextView) findViewById(R.id.title);
resolveIntent(getIntent());
}
Change your Declaration activity "TagViewer" instead of ".TagViewer"
I have developed a little project using just one Activity, and now, I'm trying to add a new one, but, I recieve this error when I'm trying to launch the project on my device:
Running com.android.gl2jni/.TestActivity... 1> Starting: Intent {
cmp=com.android.gl2jni/.TestActivity } 1> 1>
java.lang.SecurityException: Permission Denial: starting Intent {
flg=0x10000000 cmp=com.android.gl2jni/.TestActivity } from null
(pid=2935, uid=2000) requires null
I'm not trying to call the new Activity, and I have developed an empty Activity to check why I can't launch the app.
This is my Manisfest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.gl2jni">
<uses-feature android:glEsVersion="0x00020000"/>
<uses-sdk android:minSdkVersion="9"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:label="#string/gl2jni_activity">
<!--main activity-->
<activity android:name=".GL2JNIActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--BT device list activity-->
<activity android:name=".TestActivity"
>
<intent-filter>
</intent-filter>
</activity>
<!--
<activity android:name=".BluetoothDeviceListActivity"
android:label="#string/select_device"
android:theme="#android:style/Theme.Dialog"
android:configChanges="keyboardHidden"
android:screenOrientation="landscape"
/>
-->
</application>
</manifest>
And this is the empty activity class:
package com.android.gl2jni;
import android.app.Activity;
import android.util.Log;
import android.os.Bundle;
public class TestActivity extends Activity {
#Override protected void onCreate(Bundle icicle) {
LogConsole.print( "HI, I AM TestActivity" );
}
}
I suppose that I have to modify something else more, but I don't know what...
Thanks in advance for the help.
You've specified an empty intent filter for TestActivity. An empty intent filter matches NO intents. Remove these lines from the block for TestActivity:
<intent-filter>
</intent-filter>
Also, in onCreate() of TestActivity you must call super.onCreate(), otherwise Android will crash it.
HY!
I always get the ActivityNotFound Error, but i already have my Activity declared in the Manifest.
Whats wrong?
Error:
10-17 20:28:24.881: ERROR/AndroidRuntime(2141): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}; have you declared this activity in your AndroidManifest.xml?
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.supplierplan"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name = "android.permission.INTERNET"> </uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".view.Login"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".view.LVEntries"></activity>
</application>
</manifest>
Calling:
Intent i = new Intent (Login.this,LVEntries.class);
i.putExtra("JSON", array.toString());
startActivity(i);
The problem is in how you are naming the Activities in you Manifest file.
I'm guessing your class files are named Login.java not view.Login.java, am I right? If so change this:
<activity android:name=".view.Login" android:label="#string/app_name">
To This
<activity android:name="Login" android:label="#string/app_name">
Do the same for LVEntries
If they are named like view.Login.java then remove the prepended view. in the name.
I'm trying to make a ticker widget for BBC News, most of it was working perfectly well last night, but I had a few issues getting the permissions for the configuration activity correct. After re-writing my Manifest nothing works at all, despite being completely how it should be as far as I can tell.
Here's my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.news.bbcwidget"
android:versionCode="1"
android:versionName="101">
<application
android:label="#string/app_name"
android:icon="#drawable/logo"
android:permission="android.permission.INTERNET"
android:persistent="true"
android:debuggable="true"
android:enabled="true">
<activity
android:name="BBCWidgetConfig"
android:permission="android.permission.INTERNET">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<activity
android:name="Launcher"
android:permission="android.permission.INTERNET" />
<receiver
android:name="BBCNewsWidget"
android:permission="android.permission.INTERNET">
<service
android:permission="android.permission.INTERNET"
android:name="BBCNewsService" />
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:resource="#xml/bbcnews"
android:name="android.appwidget.provider" />
</receiver>
<service android:name="BBCNewsWidget$BBCNewsService" />
</application>
</manifest>
and here are the key bits of the errors received:
06-19 20:06:34.339: WARN/ActivityManager(58): Permission Denial: Accessing service ComponentInfo{com.news.bbcwidget/com.news.bbcwidget.BBCNewsWidget$BBCNewsService} from pid=58, uid=1000 requires android.permission.INTERNET
06-19 20:06:34.529: ERROR/AndroidRuntime(247): java.lang.RuntimeException: Unable to start receiver com.news.bbcwidget.BBCNewsWidget: java.lang.SecurityException: Not allowed to start service Intent { cmp=com.news.bbcwidget/.BBCNewsWidget$BBCNewsService } without permission android.permission.INTERNET
06-19 20:06:34.529: ERROR/AndroidRuntime(247): Caused by: java.lang.SecurityException: Not allowed to start service Intent { cmp=com.news.bbcwidget/.BBCNewsWidget$BBCNewsService } without permission android.permission.INTERNET
06-19 20:10:51.558: WARN/ActivityManager(58): Permission Denial: broadcasting Intent { act=android.appwidget.action.APPWIDGET_DELETED cmp=com.news.bbcwidget/.BBCNewsWidget (has extras) } from android (pid=113, uid=10000) requires android.permission.INTERNET due to receiver com.news.bbcwidget/com.news.bbcwidget.BBCNewsWidget
06-19 20:10:51.558: WARN/ActivityManager(58): Permission Denial: broadcasting Intent { act=android.appwidget.action.APPWIDGET_DISABLED cmp=com.news.bbcwidget/.BBCNewsWidget } from android (pid=113, uid=10000) requires android.permission.INTERNET due to receiver com.news.bbcwidget/com.news.bbcwidget.BBCNewsWidget
It was previously giving "bad process" errors but that seems to have stopped now. From what I understand the Manifest is giving android.permission.INTERNET to all of my services, activities and the AppWidgetProvider, so I don't understand why this is happening. it used to work before!
Cheers!
Add
<uses-permission
android:name="android.permission.INTERNET"></uses-permission>
To your manifest node and not to the activities
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.news.bbcwidget"
android:versionCode="1"
android:versionName="101">
<application
....
</application>
<uses-permission
android:name="android.permission.INTERNET"></uses-permission>
</manifest>