Good day,
I have an application which connects my android device to an arduino unit through a service. I have managed to make the connection but it keeps asking me for permission to use the accessory whenever I plug it in. Is there any way to bypass this permission? It works perfectly with an intent filter if I do it through an activity, I have tried applying the same intent in the service but it does not seem to work :/.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="blink.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-feature android:name="android.hardware.usb.accessory" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ActivityCreate">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".StartupIntent" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name=".MainService"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="#xml/accessory_filter" />
</service>
<uses-library android:name="com.android.future.usb.accessory"/>
</application>
</manifest>
Here is the code in my manifest.
Thanx
To bypass permission you must make your app a system app. To make an app run as a system app you must place the apk in system/app folder. For doing that i first remounted the system drive as rw (read-write) using adb using the following code:
adb remount rw
push "apk path" /system/app
adb remount ro
Now reboot the system. Android will no longer ask for permission.
Related
I am trying to add Voice Capabilities in Android Wear and following below URL
https://developer.android.com/training/wearables/apps/voice.html
Here is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demowearapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="20"
android:targetSdkVersion="20" />
<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>
<activity
android:name=".TaxiActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" />
</intent-filter>
</activity>
</application>
</manifest>
But when i am trying below voice commands in my LG G watch it doesn't open my activity...it just showing Google search results
"OK Google, get me a taxi"
"OK Google, call me a car"
Thanks.
The wearable doesn't know this is a wear app. Wear apps need this in their manifest: <uses-feature android:name="android.hardware.type.watch" />
Had the same problem. The solution was to add the category android.intent.category.DEFAULT to the intent filter:
<activity android:name=".TaxiActivity" android:label="#string/app_name">
<intent-filter>
<action android:name="com.google.android.gms.actions.RESERVE_TAXI_RESERVATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
If you open the Android Wear app on the phone you can verify that your app is available under "Call a car" beneath "Voice actions".
For non-English speakers still having problems using the voice command you should double check the language used for voice commands on your device. Change it to English and try it out. If that still doesn't work you can try changing the device's language to English also.
I have developed a android wear demo application. The Android wear description mentions that the wear application is automatically installed on the wear device when installed on the mobile device.
My problem is now that this does not work. The app was created with Android studio.
Wenn I start the waer (sided) app with debugging enabled it installs the app on the wear device and it works ok. Once I install the mobile app (which includes the waer app) the wear on the wear device is deleted, bit the waer not installed on the wear device anymore.
Same happens when I want to debug the apps. Whenever I debug the mobile app the app on the wear device is deleted but not installed.
As written the curios thing is that I can install the wear app directly from within Android stuudio.
All the settings look ok, created automatically by Android studio.
The mobile manifest looks like that:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.waldhoer.klemens.klemenswearsampleapp" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".KlemensActivity"
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=".FallRecognitionService" android:enabled="true"></service>
<service android:name=".DataLayerListenerService" android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
The wear manifest like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.waldhoer.klemens.klemenswearsampleapp" >
<uses-feature android:name="android.hardware.type.watch" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault" >
<activity
android:name=".KlemensWearActivity"
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=".WearFallRecognitionService" android:enabled="true"></service>
<service android:name=".DataLayerListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
<uses-permission android:name="android.permission.BODY_SENSORS" />
</manifest>
I also created a release version of the (mobile) app with Key signed, did not change anything.
Any idea what could be wrong? Thanks for help!
I am getting a strange issue, please see if anyone can help here. Whenever I run my app (either in emulator or in phone), I can see the installation goes successful but the activity does not show up. Following is the message I get in the Console.
------------------------------
Android Launch!
adb is running normally.
Performing sync
Uploading MyApp.apk onto device 'emulator-5554'
Installing MyApp.apk...
Success!
\MyApp\bin\MyApp.apk installed on device
Done!
It was running normally before but since yesterday, it has started to behave like this. Ideally after "Success!" statement, the intent gets loaded and MainActivity shows up. But not anymore. I tried restarting/recreating emulator but no help. The only change I had done in my app was to create some xml files for titlebar. I even undid that change but still the same issue. Any help is appreciated.
UPDATED TO ADD MANIFEST FILE
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bfp.MyApp"
android:versionCode="12"
android:versionName="2.5" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<permission
android:name="com.bfp.MyApp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.bfp.MyApp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme" >
<activity
android:name="com.bfp.MyApp.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.bfp.MyApp.TestQuizActivity"
android:parentActivityName="com.bfp.MyApp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.bfp.MyApp.MainActivity" />
</activity>
<service android:name="com.bfp.MyApp.GCMIntentService" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.bfp.MyApp" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.bfp.MyApp" />
</intent-filter>
</receiver>
<activity
android:name="com.bfp.MyApp.RegisterActivity"
android:launchMode="singleTop" />
<activity
android:name="com.bfp.MyApp.BaseActivity"
android:label="#string/title_activity_main" >
</activity>
</application>
Does your app run correctly when you run it from the phone directly? If so, perhaps you accidently changed the run configuration from eclipse to launch other activity than you MainActivity. This affect running from eclipse via the debug interface.
Looks like the problem was more while running the app from eclipse. Installing the apk file in phone was working fine. I deleted the AVDs and recreated them. Also I noticed that my app had reference to android ver 4.3 whereas the intel atom image was not available for that version. hence I downgraded it to 4.2.2. With these changes done, the app started loading normally. Not really what was the root cause, but something to do with the AVD was the issue.
I have an application that I want to test on real device, and I have a Samsung Galaxy Mini which runs on android 2.3.6, but since the only available SDK for that is 2.3.3, I have selected that as a target build. When I plugin in USB ,windows does recognize it but eclipse does not, it won't install app on the device nor show it when the emulator is also running. Is it some kind of bug or what?
This is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidhive"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ng_icon"
android:label="#string/app_name" >
<activity
android:name=".Init"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.androidhive.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CurentNews"
android:label="#string/title_activity_curent_news" >
<intent-filter>
<action android:name="com.example.androidhive.CURENTNEWS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".News"
android:label="#string/title_activity_news" >
<intent-filter>
<action android:name="com.example.androidhive.NEWS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
I think the problem is in device driver.
Can you please
Check output of "adb devices" command in console?
If nothing - check whick driver is installed for the device, and if necessary - manually install AndroidPhone -> ADB Debug Interface (In a list of system drivers)
Also check if "Allow USB debugging" is on in phone's Developer Settings.
PS: If no driver is found in the system - use SDK Manager to download GoogleUSB Driver, it will appear in "Extras" folder in Android SDK.
Good luck
I have been able to create a *.apk file from my code, place the file
in IIS, and download it onto a number of Android phones. Upon the
install, the application works exactly as expected.
However, after a phone is rebooted, the application name is changed to
the fully-qualified Java class name of the activity in the menu (so
"MyActivity" becomes "com.mycompany.MyActivity"), and when I try to go
to Menu > Settings, I get an error that causes android to force close
my application.
Looking into DDMS, I see that I get an error indicating that it can
not find my Preferences activity, despite the fact upon initial
install, it works properly.
I'm using Eclipse on Windows XP, and have several Android devices at
my disposal to test with.
Any idea what's going on?
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name="com.company.app.ActivityMain"
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="com.company.app.Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name="com.company.app.Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
So I finally got this to work. I think that the package installer on the HTC Hero (and maybe the HTC Droid Eris) has some issues.
I uninstalled my application from the phone, changed the name of my main activity, and re-deployed it onto the Hero. I started to immediately get a "Force Close." I connected the device to DDMS and looked at the error. It was still looking for my old activity name. I factory reset the device and reinstalled the same package (with the updated name) and everything works as expected.
So it seems that the package installer is caching some part of the old manifest or something, not really sure what exactly is going on there. I may play with it some more if I get time.
I don't know if someone else could verify this problem, maybe it's something that should be taken up with HTC?
try to use this manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/logo" android:label="#string/app_name"> <!--android:debuggable="true">-->
<activity android:name=".ActivityMain"
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=".Preferences"
android:label="#string/app_settings">
<intent-filter>
<category android:name="android.intent.category.PREFERENCE"></category>
<action android:name="android.intent.action.MAIN"></action>
</intent-filter>
</activity>
<service android:name=".Service"></service>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>