I just have read that Android M performs bluetooth scanning even when the bluetooth is off
(Here is the first question: Is it only BLE scanning?).
So i thought it would be reallly nice to intercept that scanning data to discover the beacons.
I tried to register a broadcast receiver for android.bluetooth.device.action.FOUND in Manfest.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".BluetoothReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.bluetooth.device.action.FOUND" />
</intent-filter>
</receiver>
</application>
Unfortunetally that broadcast only comes on Android 5.1 and less but not the M.
Is there any way to intercept that scnanning data in order to save a battery and not running a service that manually performs scans, as the Android Beacon Library from Radius Network does?
Related
I have stumbled upon a problem I just can't seem to fix.
2 scenarios, in the first a user clicks a button which fires a method in MainActivity to make a web request. This works, no problem at all.
In the second scenario I want to make this request automatically in a service running in the background, as soon as the code moves into the Service, it makes a permission exception.
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
I can start up the service perfectly fine, but if I move any network requests into the service then I get into permission problems.
I already have <uses-permission android:name="android.permission.INTERNET"/> and <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>in my AndroidManifest.xml file.
I also do realtime permission checking (SDK 23+) in my MainActivity before starting the service, but this seems to have no effect on the permissions that the service gets.
Any ideas?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="domain">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="domain.RemoteCommunicationService"
android:isolatedProcess="true"
android:exported="true">
</service>
<receiver android:name="domain.RemoteServiceRestartReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="domain.RemoteServiceRestart"></action>
</intent-filter>
</receiver>
<receiver android:name="domain.RemoteCommunicationService$RemoteCommunicationReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="domain.RemoteCommunication.ToggleLight"></action>
</intent-filter>
</receiver>
</application>
You have use isolateProcess to true. Read what docs has to say:
If set to true, this service will run under a special process that is isolated from the rest of the system and has no permissions of its own. The only communication with it is through the Service API (binding and starting).
I have added below permission and defined broadcast receiver
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<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>
<receiver android:name=".CheckLockBroadCastReciever" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<!--<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />-->
</intent-filter>
</receiver>
</application>`
My defined receiver is calling when I am doing mobile data on/off in jellybeans os, KitKat os and lollipop os but the receiver is not invoking in marshmallow and nougat.
Use permission:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Also, try to register your reciever inside onCreate and don't forget to unregister and register inside onPause and onResume respectly.
The network changes listener implementation for android N and high
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
registerReceiver(mNetworkReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Please refer https://developer.android.com/about/versions/nougat/android-7.0-changes.html
I am trying to intercept the only one button on a bluetooth headset. I have tried many things found on the site but none worked. The main activivity manages the bluetooth connection (using a code from https://github.com/sauravpradhan/AnySound2BT).
I have the following manifest file :
...
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppBaseTheme" >
<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>
<intent-filter android:priority="2147483647">
<action android:name="android.intent.action.VOICE_COMMAND"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".MyReceiver" >
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED" >
</action>
</intent-filter>
</receiver>
...
When I click once, nothing happens and the second time the phone asks me to start "S voice" or "Google appli".
Thanks for any hint
Karim
Their are many methods to intercept the button function if this button really did something.
According to your description, the phone asks you to start "S voice" or "Google appli" then I assume one of the button's combined function is "Voice Recognition Activation".
You can export the btsnoop log of the Android, then click the HFP tab, to find out the AT command, then you can understand what the button sends.
Note that for all of the button on the headset, the long press,short press, and continue short press, the the press during calling or not calling,might have different meaning.
I am happily receiving notifications when app is in background and foreground but when app is killed, I am not receiving notifications in some phones (like Xiaomi model phones eg mi3, etc.)
GCM message 0:1434141725194227%03b66390f9fd7ecd
broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg= (has extras) }
Although I am getting notifications in other phones like nexus, samsung, others.
Did anyone also had similar problem?
Can someone explain me where I am wrong.
Here is my Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<package_name>">
<permission android:name="<package_name>.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="<package_name>.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED"/>
<action android:name="android.net.wifi.STATE_CHANGE"/>
<application
android:name="<package_name>.ApplicationSingleton"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="<package_name>.ui.activity.ReferralActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="<package_name>.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="<package_name>" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="<package_name>"/>
</intent-filter>
</receiver>
<service android:name="<package_name>.gcm.GcmIntentService" />
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Autostart probably the best MIUI feature that doesn’t come enabled by default, but should.
What does autostart do? It basically starts the apps you select when the phone starts, so you never miss any notifications or updates.
To enable autostart for your apps, follow the steps below:
Tap on the Security app from the app screen.
You will not find this if you enter from the Settings menu, you have to tap directly on the app icon.
Open Security App:
Once in the Security app, tap on Permissions.
Tap on Autostart
Toggle the apps you want to enable Autostart for
Reboot your phone.
Now you are all set up with autostart!
i am working on an app that will automatically decline incoming calls from specific numbers and send an sms in return.my broadcast receiver should be enabled from my app only.
so, i added ( android:enabled="false" ) this. but, the receiver is still on by default. i'm struck here.
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.sifydy.automsgr.Automsgr"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.sifydy.automsgr.Receiver"
android:label="#string/app_name"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
wen i switch on my mobile, my receiver is also activated wen ever there is an incoming call.
i am able disable it from my app. everything is fine once i am in my app. how to disble it by default?