Launch activity with custom permission through adb - android

I am trying to launch an activity using adb. If I remove the custom permission tag android:permission from below snippet from manifest (manifest stripped for brevity), then everything is working fine.
<manifest ... package="com.example.pkgname">
<permission android:name="com.example.pkgname.BIND"
android:protectionLevel="normal"/>
.
.
.
<uses-permission android:name="com.example.pkgname.BIND" />
<application android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:name="com.example.pkgname.ManagerApplication"
android:supportsRtl="true" android:theme="#style/Theme.Security.Main">
<activity
android:exported="true"
android:launchMode="singleTask"
android:name="com.example.activity1"
android:permission="com.example.pkgname.BIND" />
</application>
</manifest>
I tried this : adb shell am start -n com.example.pkgname/com.example.activity1
which threw below error :
Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.example.pkgname/com.example.activity1 } from null (pid=16893, uid=3000) requires com.example.pkgname.BIND
How do I launch activity with custom permissions through adb?

Related

Missing MainActivity Error when running on Android TV Emulator

I created a sample Android TV app for testing purposes. I followed the documentation at
https://developer.android.com/training/tv/start/start
This is how my manifest file looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.CourseViewer">
<activity
android:name=".MainActivity"
android:banner="#drawable/app_icon_your_company"
android:exported="true"
android:icon="#drawable/app_icon_your_company"
android:label="#string/title_activity_main"
android:logo="#drawable/app_icon_your_company"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DetailsActivity"
android:exported="false" />
<activity
android:name=".PlaybackActivity"
android:exported="false" />
<activity
android:name=".BrowseErrorActivity"
android:exported="false" />
</application>
</manifest>
This is what I get when I run the app on an android tv emulator. Can someone please let me know what is missing in the manifest file? I do have the MainActivity and the manifest looks fine to me.
02/20 11:38:56: Launching 'app' on Android TV (4K) API 33.
Install successfully finished in 824 ms.
$ adb shell am start -n "edu.app.courseviewer/edu.app.courseviewer.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "edu.app.courseviewer/edu.app.courseviewer.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.app.courseviewer/.MainActivity }
Error type 3
Error: Activity class {edu.app.courseviewer/edu.app.courseviewer.MainActivity} does not exist.
Error while Launching activity
Failed to launch an application on all devices
I have tried restarting android studio, invalidating caches and restart, synced gradle files. I was hoping the app would start on Android TV emulator.

Android Permission: App crashes needing bluetooth permission

I was recently creating an app that uses bluetooth. The problem is my app crashes when ever I start the bluetooth service. Here's my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.petalappstudio.fit" >
<uses-permission android:name="ANDROID.PERMISSION.BLUETOOTH"/>
<uses-permission android:name="ANDROID.PERMISSION.BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
<service
android:name=".bluetoothManager"
android:enabled="true"
android:exported="true">
</service>
</application>
Now as you can see I have added permission for bluetooth and bluetooth admin.
How ever my app crashes and in LOGCAT the error is
"java.lang.RuntimeException: Unable to start service " and is caused by
"java.lang.SecurityException: Need BLUETOOTH ADMIN permission: Neither user 10145 nor current process has android.permission.BLUETOOTH_ADMIN."
But I have added permission as you can see. Now why is this happening ?
Try to add one more permission :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Refe. : Android Permission BLUETOOTH Manifest error
Note : also check device support Bluetooth feature or not using :
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />

LAUNCHER open: Permission denied

Testing Navigation Drawer with Material Design App. When I run the app in Android Studio, I got the following error. App is installed in my phone but could launch. Please let me know what permission I am missing to add.
Launching application: com.jobsclipper.jobs/com.jobsclipper.jobs.MainActivity.
DEVICE SHELL COMMAND: am start -n
"com.jobsclipper.jobs/com.jobsclipper.jobs.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER open:
Permission denied open: Permission denied Starting: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
cmp=com.jobsclipper.jobs/.MainActivity }
Here is My manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobsclipper.jobs"
android:versionCode="1"
android:versionName="1.0" >
<!-- for most things, including card.io & paypal -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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=".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>

ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.act

I have a problem...
I'm making a simple program about GIS, and when I'm trying to launch it from eclipse to my device, I get warning when I check the console.
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.warteg.GIS/.Splash } from null (pid=16196, uid=2000) requires null
and the program is not installed in my device, but when I try with emulator from eclipse, the program is launched.
Can someone solve my problem? Here's my manifest XML.
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="Splash"
android:label="#string/app_name">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps"></uses-library>
<activity android:name=".Splash"></activity>
<activity android:name=".FormPetunjuk"></activity>
<activity android:name=".Peta"></activity>
</application>
your are registering Splash activity two times in manifest.xml so remove this one:
<activity android:name=".Splash"></activity>

java.lang.SecurityException: Permission Denial: starting Intent

I am a newbie to Android application development... When i try to run my application i am getting a security exception as Permission Denial... though i am able to open my application i am unable to proceed to any of the process... Application doesn't access the web service... Plz help me out...
The following is the exception message I receive,
[2012-01-11 11:02:09 - eCalc] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.anb.eCalculator/.LoginActivity } from null (pid=-1, uid=-1) requires android.permission.INTERNET
enter code here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anb.eCalculator"
android:installLocation="internalOnly"
android:versionName="1.2.1" android:versionCode="10">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:label="#string/app_name"
android:theme="#android:style/Theme"
android:permission="android.permission.INTERNET"
android:icon="#drawable/ecalcicon" android:allowClearUserData="true">
<activity android:name=".LoginActivity"
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=".CalculationActivity"></activity>
<activity android:name="ResultActivity"></activity>
<activity android:name=".InformationActivity"></activity>
<activity android:name=".RegisterActivity"></activity>
<activity android:name=".SettingsActivity"></activity>
<activity android:name=".ResultDetailsActivity"></activity>
<activity android:name=".Disclaimer"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:targetSdkVersion="5"
android:minSdkVersion="5"
android:maxSdkVersion="12">
</uses-sdk>
<uses-permission android:name="android.permission.INTERNET" />
Add this above line in your manifest file after your <uses-sdk> line.
Add this permission to your manifest file.
<uses-permission android:name="android.permission.INTERNET" />
I fixed it .
Click on "Run" and "Edit configuration". Select the activity you want to launch.

Categories

Resources