My app is a launcher that I make the default right after the installation and it does read NFC tags without problems on the first launch but if I lock the phone and them unlock it (at this point my app is already on screen and onResume() is called) the app stops to read the tags (a different sound is played when an tag is read by the phone, I guess it's the NFC fail sound) and the onNewIntent(Intent intent) is not called.
I already tried to make my filters and intents being activity scoped instead of local (removed from setupForegroundDispatch) but stills the same problem. If I reopen the app (kill and start again) then the NFC reader does read right.
So below is my logic:
NfcAdapter nfcAdapter;
#Override
protected void onResume() {
super.onResume();
if (nfcAdapter == null){
nfcAdapter=NfcAdapter.getDefaultAdapter(this);
}
setupForegroundDispatch(this, nfcAdapter);
}
public static void setupForegroundDispatch(Activity activity, NfcAdapter adapter) {
final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
final PendingIntent pendingIntent = PendingIntent.getActivity(
activity.getApplicationContext(), 0, intent, 0);
IntentFilter[] filters = new IntentFilter[2];
String[][] techList = new String[][]{};
filters[0] = new IntentFilter();
filters[0].addAction(NfcAdapter.ACTION_TAG_DISCOVERED);
filters[1] = new IntentFilter();
filters[1].addAction(NfcAdapter.ACTION_TECH_DISCOVERED);
adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String action = intent.getAction();
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) ||
NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
if (tag != null) {
//do my logic here
}
}
}
#Override
protected void onPause() {
super.onPause();
nfcAdapter.disableForegroundDispatch(this);
}
My manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.org.company.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:sharedUserId="android.uid.system"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:versionName="1.2.1xdk"
android:usesCleartextTraffic="true">
<meta-data
android:name="com.google.android.actions"
android:resource="#xml/actions" />
<receiver android:name=".receivers.GpsLocationReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.location.LocationManager.KEY_LOCATION_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.PassiveLocationChangedReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.location.LocationManager.KEY_LOCATION_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.BootReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.BOOTUP_COMPLETE" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver android:name=".receivers.MyWakefulReceiver" />
<receiver android:name=".receivers.InternetConnectionReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGE" />
</intent-filter>
</receiver>
<receiver android:name=".receivers.IncomingCall">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
<activity
android:name=".FirstScreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:sharedUserId="android.uid.system"
android:soundEffectsEnabled="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:sharedUserId="android.uid.system"
android:soundEffectsEnabled="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<data android:mimeType="text/pg" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/nfc_type" />
</activity>
<receiver
android:name=".AppDeviceAdmin"
android:description="#string/app_name"
android:label="#string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="#xml/app_device_admin" />
<intent-filter>
<action android:name="android.app.action.PROFILE_PROVISIONING_COMPLETE" />
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
</application>
</manifest>
On logcat there's no exceptions, seens that the NFC reads are not even delivered to my application. (After it gets back from the background and the phone reads a NFC not even the onPause(), onResume() are triggered on my application)
So far seens it's related to my application being a launcher, although I didn't find anything about this restriction.
So I found an answer to my problem; This app is a total fullscreen (internal app of the company) so in my onCreate() I had various flags to keep the app on screen and to avoid the keyguard on lock screen whenever possible (to avoid users to go to other apps) and that was the problem, my app had
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
WindowManager.LayoutParams.FLAG_FULLSCREEN
and for some reason preventing the keyguard to show up (run the app over the lock screen) disables the NFC delivery to the app (for security reasons, I guess). Since this is an internal app (and all the phones are pre seted by the I.T team) the solution was to manually remove the keyguard from lock screen by phone settings and remove the flags
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
so everytime the user locks and unlocks the phone the sistem enables the NFC reader again.
Related
I am new to android and I'm having this problem
if the app is in the foreground the notification shows normally
if I put the app in the background the notification will show and it works normally also
BUT the problem is -> when I close the application(the app is killed) the notification does not show <-
solutions I tried
only send notification
only send data
not putting a custom view for the notification
what I understand is if I send only notification without data it will show when the app is in the foreground AKA when it's open and you can see it and
if I only send data without notification it will show in the background and when the app is killed and the data will be found in the main activity intent (but clearly this is NOT the case for me)
I am using an android 10 Infinix Note 5 stylus just in case there is something with this model
but I still can see notifications from any other app normally
edit
so I tried to run the app on other phones and it works as it supposed to but on my phone all the notifications that is sent when the app is closed will only show when I open the app
I close the app -> send some notifications -> no thing on the phone ->
open the app again -> all the notifications I sent are are now there
it still works fine when i send the notifications when the app is on foreground and when i put it in the backgorund
code:
public class FirebasePushNotificationConfig extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
sendNotification(remoteMessage);
}
private void sendNotification(RemoteMessage remoteMessage) {
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(AppStrings.MSG.name(), "Testing", NotificationManager.IMPORTANCE_DEFAULT);
channel.enableVibration(false);
channel.enableLights(true);
manager.createNotificationChannel(channel);
}
PendingIntent pendingIntent = getPendingIntent(remoteMessage);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, AppStrings.MSG.name())
.setSmallIcon(R.drawable.ic_notifications_black_24dp)
.setVibrate(null)
.setContentTitle(remoteMessage.getData().get(AppStrings.MSG.name()))
.setContentText(remoteMessage.getData().get(AppStrings.MSG.name()))
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.setContentIntent(pendingIntent);
Notification n = mBuilder.build();
manager.notify(1, n);}
private PendingIntent getPendingIntent(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, LoginActivity.class);
intent.putExtra(AppStrings.Notifications_Data.name(), remoteMessage.getData().get(AppStrings.Notifications_Data.name()));
intent.putExtra(AppStrings.Is_There_Notification.name(), AppStrings.YES.name());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(AppStrings.Notifications_Destination.name(), remoteMessage.getData().get(AppStrings.Notifications_Destination.name()));
return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
}
#Override
public void onNewToken(String token) {
super.onNewToken(token);
System.out.println("log Token is " + token);
Log.d("Test", "token: " + token);
}}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.test">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.SET_ALARM " />
<uses-permission android:name="android.permission.READ_PHONE_STATE " />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS " />
<uses-permission android:name="android.permission.READ_SMS " />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".Config.App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".LocationActivity"></activity>
<activity android:name=".MapsActivity" />
<!-- <activity android:name=".ProfileActivity" />-->
<activity android:name=".ChatManagerActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity" />
<activity android:name=".AuthActivity" />
<activity android:name=".ChatActivity" />
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name=".LoginActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver
android:name=".broadcastRecivers.AlertReciver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver
android:name=".broadcastRecivers.LoginReciver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name=".Config.FirebasePushNotificationConfig"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="key" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.test.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
</application>
</manifest>`
the data I send looks like this
{"to":"key"
,"notification":{
"title":"hello it's test"
,"body":"still a test"
},
"data": {
"Notifications_Destination" : "direction"
,"MSG":"this is a test notifiation",
"Notifications_Data":5
}}
create FcmHelper class with extends FirebaseMessagingService.
<!--Fcm Starts-->
<service
android:name="google_classes.FcmHelper"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_noti" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/black" />
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="true" />
<!--Fcm End-->
Try this:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
and under application tag add:
<service android:name=".FirebaseService"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Change class names as per requirements.
I have tried every solution on the internet. But none of them worked for me. Could you check where I am doing wrong?
Maybe it no longer works in higher Api.
Here is my broadcastReceiver class :
public class ReceiverToStartAnApp extends BroadcastReceiver {
#Override
public void onReceive(final Context context, Intent intent) {
Toast.makeText(context, "Home Task 3 Version ", Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(context, CameraRecorderActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
Here is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hometaskversion3">
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.HomeTaskVersion3">
<activity
android:name=".ui.CameraRecorderActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".service.RecorderService" />
<receiver
android:name=".receiver.ReceiverToStartAnApp"
android:directBootAware="true"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.BOOT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
First of all, apps that have never been started in some way do not receive system broadcasts. So you need some activity of your app to start before you receive ACTION_BOOT_COMPLETED.
Second, as noted in the comments, it is no longer allowed to start an activity from a receiver unless some conditions are met. The preferred way to do it is to show a notification with a pending intent for the activity you need to start. This approach will be less intrusive for the user.
Hi i want to disable (delete) these permissions from my app
WRITE EXTERNAL STORAGE
READ_EXTERNAL_STORAGE
WAKE_LOCK
and disable using camera and taking photos
the source code of users permissions in my app, I am using android studio.
that is the source how will be the new ??
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bpositive"
android:versionCode="2"
android:versionName="1.0.3" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" /> <!-- Permissions required for GCM -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.bpositive.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.bpositive.permission.C2D_MESSAGE" />
<application
android:name="sample.bpositive.sparkleappz.app.BPlus"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name="sample.bpositive.sparkleappz.activities.SplashActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="sparkleappz.com/"
android:scheme="http" />
<data
android:host="sparkleappz.com/"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="sample.bpositive.sparkleappz.activities.MainActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name="sample.bpositive.sparkleappz.activities.ResetPasswordActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name="sample.bpositive.sparkleappz.activities.DonateActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme"
android:windowSoftInputMode="stateHidden" >
</activity>
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<service android:name="sample.bpositive.sparkleappz.MyFirebaseMessagingService" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="sample.bpositive.sparkleappz.MyFirebaseInstanceIDService" >
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="#style/Theme.AppCompat.Light.DarkActionBar" /> <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
<activity
android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
android:theme="#style/Theme.IAPTheme" />
<activity
android:name="com.google.android.gms.appinvite.PreviewActivity"
android:exported="true"
android:theme="#style/Theme.AppInvite.Preview" >
<intent-filter>
<action android:name="com.google.android.gms.appinvite.ACTION_PREVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<!--
FirebaseMessagingService performs security checks at runtime,
no need for explicit permissions despite exported="true"
-->
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:permission="android.permission.INSTALL_PACKAGES" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.bpositive" />
</intent-filter>
</receiver>
<!--
Internal (not exported) receiver used by the app to start its own exported services
without risk of being spoofed.
-->
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<!--
FirebaseInstanceIdService performs security checks at runtime,
no need for explicit permissions despite exported="true"
-->
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.bpositive.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
Hi i want to disable (delete) these permissions from my app
WRITE EXTERNAL STORAGE
READ_EXTERNAL_STORAGE
WAKE_LOCK
and disable using camera and taking photos
the source code of users permissions in my app, I am using android studio.
that is the source how will be the new ??
There is a line in your file that reads
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and one that reads
<uses-permission android:name="android.permission.WAKE_LOCK" />
If you delete them and rerun gradle, your project will now no longer have those permissions.
Remove this lines from your
AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
to remove the permissions
You can't just remove permissions and hope your app to work if permissions are essential for that to work or triggered on user interaction like touching camera button to invoke camera and require camera permissions. If that app requires that permissions you remove those permission you will get errors especially that apps targets for above Android 6.0 with android:targetSdkVersion="25".
If you are hoping to publish that app with JUST RESKIN you will get a strike because publishing a spam app. You should do some modification on that app to be considered as modified work. You should also check licanse for license whether you are allowed to do or not.
After following this tutorial:
https://parse.com/apps/quickstart#parse_push/android/native/existing
and this one:
http://www.androidhive.info/2015/06/android-push-notifications-using-parse-com/
and reading all the related questions on stackoverflow, I still can't figure out why Parse is telling me the devices are all outdated.
Here's the Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<permission android:protectionLevel="signature"
android:name="com.myPackage.myApp.C2D_MESSAGE" />
<uses-permission android:name="com.myPackage.myApp.C2D_MESSAGE" />
...
<service android:name="com.parse.PushService"/>
<receiver android:name=".Receiver.CustomPushReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.myPackage.myApp"/>
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE"/>
<action android:name="com.parse.push.intent.DELETE"/>
<action android:name="com.parse.push.intent.OPEN"/>
</intent-filter>
</receiver>
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:myAppAndroidUser" />
And the Application looks like this:
// Parse config
Parse.enableLocalDatastore(this);
ParseCrashReporting.enable(this);
Parse.initialize(this, "[app key]", "[client key]");
ParseFacebookUtils.initialize(this);
ParseInstallation parseInstallation = ParseInstallation.getCurrentInstallation();
ArrayList<String> channels = new ArrayList<>();
channels.add("global");
PushService.setDefaultPushCallback(getApplicationContext(), MainActivity.class);
ParsePush.subscribeInBackground("", new SaveCallback() {
#Override
public void done(ParseException e) {
Log.d("Application", "Subscribed to ParsePush");
}
});
parseInstallation.put("channels", channels);
parseInstallation.saveInBackground();
I'm using Lollipop and Parse 1.9.3
I even see the log statement "Subscribed to ParsePush," so I must be close...
OK, I think I finally figured it out, since I got a notification to go through successfully from Parse (FINALLY!)
I replaced the custom receiver (that was part of one of the tutorials) with this:
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
Not totally sure why that worked, but that's what did it, I think.
I am trying to remove a shortcut from the home screen that my app has already added. I have tried the methods in these links but I can't figure out how to adapt their solutions to my code. I dont have a rooted device so I cant find the URI.
https://codinggeekorg.wordpress.com/2011/01/31/android-home-screen-shortcuts-part-iii-remove-shortcuts/
Trying to UNINSTALL_SHORTCUT but shortcut won't go away
Android: Remove app shortcut from home screen
Here is where I create the shortcut:
protected void ShortcutCreatorActivity(String number, String message, String name) {
Intent shortcutIntent = new Intent(getApplicationContext(), ShortCutActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.putExtra("number", number);
shortcutIntent.putExtra("message", message);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
This is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abezukor.autosms" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".RelativeLayoutActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".ListViewActivity"
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=".ShortCutActivity"
android:label="AutoSms">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Thanks for your help in advance.