I have a provider in my app
<provider android:authorities="com.myapp.android.provider" android:exported="false" android:name="com.myapp.android.provider.FileSystemProvider">
<grant-uri-permission android:pathPrefix="/"/>
</provider>
And when I call the following intent:
Intent intent = new Intent();
intent.setClassName(getPackageName(), "com.myapp.android.CameraActivity");
intent.setData(Uri.parse("content://com.myapp.android.provider/"));
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
I get exception
Caused by: java.lang.SecurityException: Permission Denial: starting
Intent { dat=content://com.myapp.android.provider/ flg=0xc3
cmp=com......../com......... (has extras) } from
ProcessRecord{44955bc0 9477:com...../u0a260} (pid=9477,
uid=10260) not exported from uid 10261
What I do wrong? I tried to specify full path to a file or different directory, but it never worked.
intent.setClassName(getPackageName(), "com.myapp.android.CameraActivity");
Most likely, this is not the actual line of code that is in your app; your real code is specifying some other app. Regardless, this component is not exported, and therefore you cannot access it from your app.
<provider android:authorities="com.myapp.android.provider"
android:exported="true"<----- change android:name="com.myapp.android.provider.FileSystemProvider">
<grant-uri-permission android:pathPrefix="/"/>
</provider>
Related
My Mobile version is 12. Work App properly but I upgrade my software version of mobile then crushes.
Show this Error on my log:
2022-03-01 12:04:55.025 31242-31291/com.Solver.Solver E/AndroidRuntime: FATAL EXCEPTION: WorkManager-WorkManagerTaskExecutor-thread-0
Process: com.Solver.Solver, PID: 31242
java.lang.IllegalArgumentException: com.Solver.Solver: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:147)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:124)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:79)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
I am solved this error.
I Implements this code.
implementation "androidx.work:work-runtime:2.7.1"
Your passing unexpected flags into a PendingIntent.
For example:
int intentFlags = PendingIntent.FLAG_ONE_SHOT;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
intentFlags = PendingIntent.FLAG_ONE_SHOT|PendingIntent.FLAG_IMMUTABLE;
}
After several attempt to fix this, i gave up and try to contact Qiscus. And they release new version that handle this Pending Intent behaviour change. So if anyone use Qiscus and got this error, you can use latest tag
https://github.com/qiscus/qiscus-sdk-android/releases/tag/1.3.35
PendingIntent pendingIntent;
Intent openIntent = new Intent(context, QiscusPushNotificationClickReceiver.class);
openIntent.putExtra("data", comment);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
pendingIntent = PendingIntent.getBroadcast(context, QiscusNumberUtil.convertToInt(comment.getRoomId()),
openIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);
} else {
pendingIntent = PendingIntent.getBroadcast(context, QiscusNumberUtil.convertToInt(comment.getRoomId()),
openIntent, PendingIntent.FLAG_CANCEL_CURRENT);
}
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
i have problem
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
--->Could not connect to remote process. Aborting debug session.
I did
--->adb kill-server && adb start-server
--->invalidate cache / restart
but not work yet
image1:--> [1]: https://i.stack.imgur.com/HZF5D.png
image2:--> [2]: https://i.stack.imgur.com/hrE4a.png
I don't know why, but I was able to solve this by setting android:exported = "true" for the first Activity to launch.
<activity
android:name = ".ui.top.TopActivity"
android:exported = "true"
android:label = "#string/app_name">
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</ intent-filter>
</ activity>
I have an android app that does not require a log in, but I do have Anonymous sign-in enabled so that I can retrieve the userID from Firebase and use it to log specific events. I have the feeling that it just stopped retrieving the UID from Firebase.
What I've done to resolve the issue is the following:
updated all the dependencies
updated the emulator
Installed a new emulator
re-added the google services plugin
re-added google-services.json file
updated Android Manifest
I've tried to create a login-activity for the sake of testing, where through a button with an onclicklisterer, the user get's anoynmously logged in.
I've doubled checked Local History in Android Studio to see whether big changes were made to the code, not the case. See screenshot
Enabled and disabled anonymous login from the Firebase Console.
Re-written the entire code based on documentation from Firebase.
I've basically tried every solution there is
My 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.superawesome.metime">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/wazzup"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Cardview" />
<activity android:name=".cardviewactivity" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxx" />
<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="com.google.firebase.auth.internal.FederatedSignInActivity"
tools:replace="android:launchMode"
android:launchMode="standard" />
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
My code:
#Override
public boolean onOptionsItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true; // go back to the first screen
case R.id.cardoverview:
startActivity(new Intent(this, cardviewactivity.class));
return true; //go to the screen where all the swiped right activities are stored
}
return super.onOptionsItemSelected(item);
}
#Override
protected void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
#Override
public void onComplete(#NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w("This Tag", "getInstanceId failed", task.getException());
return;
} else {
Log.d("This tag", "We need this");
}
}
});
swipeDb = FirebaseDatabase.getInstance().getReference().child("Users");
final FirebaseFirestore db = FirebaseFirestore.getInstance();
//Anonymous user login to be registered in Firebase
mAuth = FirebaseAuth.getInstance();
mCurrentUser = mAuth.getCurrentUser(); // save the UID of the user in users in Firebase without having to log in
final String UID = mCurrentUser.getUid();
DatabaseReference currentUserDb = FirebaseDatabase.getInstance().getReference().child("Users").child("UID");
currentUserDb.setValue(UID); //save the User UID to the Firebase Realtime database
// Calling to the AdMob API to add advertisements to the banner in the main view.Gotta make that dough
// Change this to big cards in the future
final AdView adView = findViewById(R.id.adView);
final AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
Screenshot to Firebase Authentication
Error I'm receiving from the logcat:
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
I/FirebaseInitProvider: FirebaseApp initialization successful
I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
V/FA: onActivityCreated
W/rawesome.metim: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
V/FA: App measurement disabled via the init parameters
I/FA: App measurement initialized, version: 28000
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
D/FA: Debug-level message logging enabled
V/FA: Detected application was in foreground
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.superawesome.metime, PID: 21746
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.superawesome.metime/com.superawesome.metime.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3341)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7478)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118)
at android.app.Activity.performCreate(Activity.java:7989)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7478)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
V/FA: Connecting to remote service
D/FA: Event not sent since app measurement is disabled
com.superawesome.metime.MainActivity.onCreate(MainActivity.java:118) --> final String UID = mCurrentUser.getUid();
I've been trying to resolve this issue for over a week now with no success
Edit:
I know I can add listeners to see if the user is anonymously signed in or not. The whole problem around this is that the user is not being signed in anymore at all.
Edit2:
From logcat:
2020-05-30 12:39:53.655 23257-23297/com.superawesome.metime I/DynamiteModule: Selected remote version of com.google.android.gms.ads.dynamite, version >= 21600
2020-05-30 12:39:53.658 23257-23297/com.superawesome.metime V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2020-05-30 12:39:53.770 23257-23311/com.superawesome.metime I/TetheringManager: registerTetheringEventCallback:com.superawesome.metime
2020-05-30 12:39:53.818 23257-23303/com.superawesome.metime W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-05-30 12:39:54.025 23257-23303/com.superawesome.metime I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2020-05-30 12:39:54.076 23257-23257/com.superawesome.metime I/FirebaseCrashlytics: Initializing Crashlytics 17.0.0
2020-05-30 12:39:54.220 23257-23257/com.superawesome.metime I/FirebaseInitProvider: FirebaseApp initialization successful
2020-05-30 12:39:54.332 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2020-05-30 12:39:54.342 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2020-05-30 12:39:54.362 23257-23332/com.superawesome.metime D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2020-05-30 12:39:54.527 23257-23315/com.superawesome.metime V/FA: App measurement disabled via the init parameters
2020-05-30 12:39:55.234 23257-23315/com.superawesome.metime I/FA: App measurement initialized, version: 28000
2020-05-30 12:39:55.247 23257-23315/com.superawesome.metime I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2020-05-30 12:39:55.267 23257-23315/com.superawesome.metime I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.superawesome.metime
2020-05-30 12:39:55.274 23257-23315/com.superawesome.metime D/FA: Debug-level message logging enabled
2020-05-30 12:39:57.009 23257-23315/com.superawesome.metime V/FA: Detected application was in foreground
2020-05-30 12:39:57.995 23257-23315/com.superawesome.metime V/FA: Connecting to remote service
2020-05-30 12:40:23.846 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:41:23.931 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
2020-05-30 12:42:54.030 23257-23311/com.superawesome.metime W/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE. Will retry token retrieval
I get java.lang.SecurityException when try to startActivityForResult(intent, requestCode); with final Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS); intent. Interesting that this crash happens only on Huawei with Android 5.1 - 5.1.1
I haven't Huawei device. Could you please give me advice what it can be.
Stacktrace
Fatal Exception: java.lang.SecurityException: Permission Denial: starting Intent { act=android.settings.USAGE_ACCESS_SETTINGS cmp=com.android.settings/.Settings$UsageAccessSettingsActivity } from ProcessRecord{11b5f1a1 19764:com.myproject.my/u0a167} (pid=19764, uid=10167) not exported from uid 1000
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2448)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496)
at android.app.Activity.startActivityForResult(Activity.java:3794)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:77)
at android.app.Activity.startActivityForResult(Activity.java:3755)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
at com.myproject.my.utils.PermissionsHelper$2.onClick(PermissionsHelper.java:134)
at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
For whatever reason, Huawei left the <intent-filter> in place for this activity, but they marked it as not exported. There is no way that you can start the activity. All you can do is catch the exception and explain to the user that you cannot navigate there.
According to android developer documentation.
In some cases, a matching Activity may not exist, so ensure you
safeguard against this.
Link : ACTION_USAGE_ACCESS_SETTINGS
I want to turn on hotspot on android phone with a specific SSID.
Whenever I hit below given code:
Method method = wifi_manager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
method.invoke(wifi_manager, wifi_configuration, true);
It gives me: java.lang.reflect.InvocationTargetException
When I added e.getCause(); it returned:
Caused by: java.lang.SecurityException: com.example.abc.magicapp was
not granted this permission: android.permission.WRITE_SETTINGS.
My Manifest file already contains these permissions:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />