I use the latest (3.4.1) version of the KNOX libraries, and trying to activate my license.
My AndroidManifest entry:
<receiver
android:name=".receiver.KnoxLicenseReceiver"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="com.samsung.android.knox.intent.action.LICENSE_STATUS" />
</intent-filter>
</receiver>
And activating the license like this:
KnoxEnterpriseLicenseManager
.getInstance(context)
.activateLicense(context.getString(R.string.const_kpe_key), getPackageName.exec())
It shows the Toast that the license was activated successfully (and works fine — I can, for example, disable the camera), but the receiver is never called.
I've tried on multiple devices with different Android versions (5.1 and 7.1) with no luck. What's wrong?
Well, Samsung docs are not correct. Correct intent action is
com.samsung.android.knox.intent.action.KNOX_LICENSE_STATUS
while action in docs is
com.samsung.android.knox.intent.action.LICENSE_STATUS
Related
I want to listen to APN Changes in my Android App.
Therefore I start a Service on android.intent.action.BOOT_COMPLETED.
This Service starts a ContentObserver which listens to changes to
content://telephony/carriers/preferapn.
I tested this setup on a few different devices (e.g. LG Spirit with Android 5.0, Samsung A3 with 6.0, Emulator Nexus5 with 7.0 and Huawei P9 Lite with 7.0)
On the Huawei phone onCreate of my Service is not called.
My other approach with android.intent.action.ANY_DATA_STATE in combination with a BroadcastReceiver which is registerd in the Manifest doesn't work either on this phone.
relevant parts of my manifest:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
...
<receiver android:name=".ConnectivityChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.ANY_DATA_STATE" />
</intent-filter>
</receiver>
<receiver android:name=".APNChangedServiceStarter" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name=".APNChangedService"></service>
Just for an update, Huawei changed the menu path in the Android 9 version.
On Huawei Mate 10 pro the way to get to this menu:
Settings -> Battery -> App launch -> Disable automatic management for your app.
A pop-up will appear, asking what you want to allow (all true by default). make sure that the first, Auto-launch is enabled
Huawei Phones have a built-in startup manager, it could be that the app is not yet enabled.
Go to Settings > All, and choose Startup manager.
This program is used to manage startup apps on Android phone.
Allow or disallow app to run automatically after the Huawei phone starts up.
I've created a webview app which hosts a website within the app in the assets-directory.
I want to update the website via an USBstick inserted in my tablets usbslot.
I tried it first with the .MEDIA_MOUNTED broadcast which doesn't work for my android 4.4. Tablet.
I've searched for an alternative and found the "MediaScannerConnection".
There are several examples here, which didn't help me much, to solve my issue.
I'm looking for an easy and clean solution and a little explanation would be nice too, to detect if an USB-Storage is connected and the chance to execute some code afterwards.
And how make this USB-check run all the time is a question in addition. I assume i have to put it in the OnResume method, but i'm not quite shure.
Please post code for your BroadcastReceiver and AndroidManifest.xml.
Manifest should look something like
<application>
<!--- ... --->
<receiver android:name=".UsbBroadcastReceiver"
android:exported="true"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<action android:name="android.intent.action.MEDIA_UNMOUNTED" />
<data android:scheme="file" />
</intent-filter>
</receiver>
</application>
Note the data tag, it's often overlooked.
In your onReceive implementation the URI to root of mount can be obtained from Intent#getData().
Also note that this will not work on Android 6.0 (M) and above. For 6.0 and above your code must request access to USB via one of two ways:
1) UsbManager#requestPermission
2) Intent#ACTION_OPEN_DOCUMENT_TREE as part of Storage Access Framework
Hi We are working on an android application where we are using reboot receiver in which I am starting few services where I am performaning some network operation.
I figured it out that in some android devices like xiaomi etc reboot receiver is not working.
Earlier I got to know that In HTC devices also it does not work so I added one more intent filter to it <action android:name="android.intent.action.QUICKBOOT_POWERON" /> then it started working fine. Now other phones like xiaomi it's still not working.
What I have to set additionally so it works fine in all the devices without asking user to update any settings manually.
<receiver
android:name="com.xyz.broadcastreceiver.ServiceStarter"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
Thanks in advance.
Xiaomi phones running MIUI have a inbuilt startup apps blocker. Maybe that is interfering with your boot receiver.
Ok, let's try again. MIUI has a a built-in Security app. In the Security app there is a 'Startup' section, where the user can configure which app can and which app can't run on startup. Your application is disabled default. Also if you examine your Logcat you can see a "permission denied" message at startup.
Put your app manually to the whitelisted apps, unfortunately that is your users can only do.
There is an internal feature of MIUI which prevents apps from restarting for saving battery & RAM. You have to manually toggle Auto Start option on in order to receive broadcast for BOOT_COMPLETED. Go to Settings> Installed Apps> Your App. Then just toggle on the auto start option. There is no option to prevent this programmatically. Instead, you can inform your app's users if they face problems while using your app (ex: Alarm is not triggering properly), they can enable Auto Start from Settings.
Try adding the android.intent.category.DEFAULT category. It is mandatory for implicit intents, but maybe it is being tweaked for some reason in Xiaomi phones and the intent is not passing one of the tests to being received by your application.
Add this in your manifest file in intent-filter
<action android:name="android.intent.action.BOOT_COMPLETED" />
You need to add
android:enabled="true"
and
android:exported="true"
exported can be false, but it is necessary to include exported.
I think it's a problem with ROM Xiaomi.eu, tested with the dev version, I used the MIUI 6.5.19 Beta version 7.4 on a Xiaomi Redmi Note 2 Prime. I have not checked with the stable version that can not be downloaded at this time for server maintenance. Broadcast receiver doesn't work on boot.
Probe the same app in a Xiaomi Mi 4 with stable Xiaomi Global ROM, MIUI 7.1.2, there worked perfectly after activating the autostart in the manager. Restart and perfectly worked the broadcast receiver and permissions required.
Now, I tested with Xiaomi.EU 7.3 stable, MIUI 7.3.2, Broadcast receiver works fine on boot and reboot. I registered my receiver with autostart in security manager, it doesn't work in ROM dev version. I don't tested with Xiaomi Official ROM Global dev.
My permissions:
<receiver android:name=".service.BootBroadcastReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.REBOOT"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Xiomi has a reported bug for only using this reciever 5 minutes after the system actually boot-up -
http://xiaomi.eu/community/threads/alarmmanager-_wakeup-problem.21430/
You can try and add the -
android:enabled="true" and android:exported="true"
even though they should be set to true by default due to manufacturer system changes
it might be different on Xiomi android customized OS.
Just pay attention for their meaning
Since the android:exported="true"
Will let other applications access to your reciever.
you should see here. In Xiaomi devices, they block some permissions even if you require it. The only way to slove it is you must allow your app this permission manually.
I was suggesting to add android:enabled="true" but it was already offered.
So I can tell you that you first make sure yourself if the receiver registered properly or not. You can also try the other version of registering it - that is doing registration programmatically (preferably in onPause() & onResume()) and see if it's receiving the broadcast message or not.
Try to disable the MUIU Optimization from the Developer Options. It worked for me.
1- Go to Settings
2- Open Additional Settings
3- Open Developer Options
4- Find the Turn on MIUI optimization
5- Disable the switch button.
I am trying to develop a setup wizard for Android, as I would like to add some functionality to the one existing from Google. Is it possible to somehow interact with the Android wizard? Because when I have searched for information I've seen that not using Google's Wizard might cause some trouble, regarding gmail account activation and so on.
If not, could an activity be called immediately before or after Google's wizard? Would it be enough to just listen to the BOOT_COMPLETED event?
Thank you very much in advance!
I don't know how you will use this unless you are making a rom and can add your app to system but basically you make your setupwizard add-on a Home activity with action MAIN, and categories HOME,DEFAULT. You should also set the priority higher than 1. If any of this is unclear you can look at the Launcher source/manifest that is publicly available.
When your activity is done it should deactivate itself with the PackageManager (setComponentEnabledSetting) and that should be it.
You can add additional activities that start the first time the phone is boot up. You just have to mimic the same behavior as Google's SetupWizardActivity.
Here's the relevant portion in the AndroidManifest.xml for reference:
<activity android:theme="#style/InvisibleNoTitle" android:label="#string/setup_wizard_title" android:name="SetupWizardActivity" android:excludeFromRecents="true" android:launchMode="singleTop" android:immersive="true">
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
This will allow you to run your application before/after SetupWizardActivity, depending on your priority. I believe higher numbers for android:prioirity run first, but don't quote me on that.
You can find out the AndroidManifest xml for various Android-related apks using apktool. You can even inspect some of apks you picked up from the Play Store or whatever other sources.
My android app should interact with our web site doing some streaming. If the user does not have the app installed we provide a webpage informing about the app and link to download it.
The info page is located at: http://my.site.no/android
And all the links are prefixed with this info page: http://my.site.no/android?url=http://something.to.stream
In the app I have declared the following intent filter:
<intent-filter>
<data android:scheme="http" android:host="my.site.no" android:pathPrefix="/android" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
This works for most devices.. but some (especially Samsung Galaxy SIII’s) refuses to register this intent filter. Even though the app is installed the user always lands on the info page. This is not just happening on the standard browser but also with other browsers like firefox and chrome on the same device. There is no “default app” settings active on the devices which refuses to register the intent.
Any idea what might be wrong ? Or how to try to debug this to find the cause ?
Probably you need to register another for the scheme "https". I had this problem with some apps and this solved it.
Had a similar problem. In my case, it was caused by the activity accidentally having set
android:exported="false"
in AndroidManifest.xml. It seems that some devices/Android versions respect this flag and some don't. In my case, it worked on a HTC Sensation (Android 4.0.3), but not on a HTC One X (Android 4.1.1) or a Samsung Galaxy S III (Android 4.1.2).