Getting SecurityException when trying to install appWidget in HomeScreen - android

am having a little trouble here. i don't know why i am getting a SecurityException, when trying to install my AppWidget on the home screen?. i don't know what will help to solve this but here is the simplified logcat output and my Android Manifest for starters:
11-30 18:02:16.454: ERROR/AndroidRuntime(287): Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.appwidget.action.APPWIDGET_CONFIGURE cmp=com.MuchachaApps.WeatherViewer/.WeatherForecastConfigure (has extras) } from ProcessRecord{44e58dc8 287:android.process.acore/10001} (pid=287, uid=10001) requires null
11-30 18:02:16.454: ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1218)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.os.Parcel.readException(Parcel.java:1206)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.startActivityForResult(Activity.java:2749)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.startActivityForResult(Launcher.java:969)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.addAppWidget(Launcher.java:1148)
113018:02:16.454:ERROR/AndroidRuntime(287):atcom.android.launcher.Launcher.onActivityResult(Launcher.java:379)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.Activity.dispatchActivityResult(Activity.java:3828)
113018:02:16.454:ERROR/AndroidRuntime(287):atandroid.app.ActivityThread.deliverResults(ActivityThread.java:3325)
11-30 18:02:16.454: ERROR/AndroidRuntime(287):... 11 more
My Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MuchaaApps.WeatherViewer"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<service android:name= "weatherForecast"></service>
<activity android:name=".WeatherForecastConfigure" android:label="#string/app_name"></activity>
<receiver android:name="WeatherWidgetProvider" android:label="Weather Forecast">
<intent-filter>
<action android:name= "android.appwidget.action.APPWIDGET_UPDATE"></action>
</intent-filter>
<intent-filter>
<action android:name="com.MuchaaApps.WeatherViewer.WEATHER_UPDATE"></action>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/weather_appwidget_info"></meta-data>
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
if you need any other information, please let me know. Thank you

Do you have a configuration Activity that's supposed to come up when you add the widget to the launcher? If so, you need to add an APPWIDGET_CONFIGURE action to your intent-filter. If not, you need to remove the android:configure attribute from your appwidget-provider XML.
Having one but not the other is the problem.

Related

BroadcastReceiver java.lang.ClassNotFoundException

I try to show a simple toast message on phone startup.
I wasted almost a day trying to figure out why my code did not work.
Here is the full error:
Unable to instantiate receiver com.debug.receivebootcomplete.debug.BroadcastReceiverClass: java.lang.ClassNotFoundException: com.debug.receivebootcomplete.debug.BroadcastReceiverClass
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.debug.receivebootcomplete.debug">
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:allowBackup="true" android:icon="#mipmap/icon" android:label="#string/app_name">
<receiver android:name=".BroadcastReceiverClass" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
And my class:
namespace Debug
{
class BroadcastReceiverClass:BroadcastReceiver
{
public override void OnReceive (Context context, Intent intent)
{
Toast.MakeText (context,"Work",ToastLength.Short).Show ();
}
}
}
In emulator debug the application throw the java.lang.ClassNotFoundException and on phone when reboot the application crash.
Thank you in advance!
Thanks #Talha!
My error was generated by the intent-filter tag. I have no idea why because in every topic that I saw everybody used that tag in Manifest file.
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
So I remove it and add
[BroadcastReceiver]
[IntentFilter(new[] {Intent.ActionBootCompleted})]
to the BroadcastReceiver class.

I haveSecurityException: Permission Denial error

I am getting the following error:
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.optionpricing/.optionListNew } from null (pid=1160, uid=2000) requires null
I am new to programming in Android and I could not make sense of the other postings related to my problem. I wonder if there is an issue with the optionListNew class? Can someone lend a hand so I can move on to completing my app. Also, the app runs in my virtual device, and I only get this error when I try to test it on my actual phone.
Any ideas are appreciated. Below is the manifest file.
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".optionListNew"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
You added "optionListNew" activity twice in the manifest file.. remove below activity by deleting this line
<activity android:name=".optionListNew"/>
Your Manifest.xml code will become
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
package="com.optionpricing" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<application android:icon="#drawable/icon"
android:label="#string/app_name"
android:debuggable="true">
<activity android:name=".optionListNew">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".OptionPricing"/>
<activity android:name=".futureOptionActivity"/>
<activity android:name=".currencyOptionActivity"/>
<activity android:name=".gapOptionActivity"/>
<activity android:name=".gapOptionList01"/>
<activity android:name=".barrierSingleUpInActivity"/>
<activity android:name=".testActivity"/>
<activity android:name=".barrierlistview"/>
<activity android:name=".barrierSingleDownInActivity"/>
</application>
</manifest>
optionListNew is present twice in the manifest. Remove the second.

ActivityNotFoundException but already declared in the Manifest

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.

Problem with permission to run an activity

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" />

Manifest file not giving permissions as it should. Permission denied when they're given in Manifest

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>

Categories

Resources