I am using the following code to request the fine location permission in my app, but when it runs, the request dialog opens behind the app so the user doesn't see it until the app is closed.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
How can I make the dialog open in front of the app, and also is there a way for my app to know when the user has answered the request (either with an accept or deny - I don't necessarily need to know which)?
Full code of the activity:
package com.myApp;
import android.Manifest;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class permissionsCheckAndSet extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_permissions_check_and_set);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
}
public void clickRequestPermissions(View v) {
Toast.makeText(this, "Request permissions now", Toast.LENGTH_LONG).show();
doRequestPermissions();
}
public void doRequestPermissions() {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
}
}
To explain the full user flow...
First of all a splash screen is displayed. This screen checks various things - network available, internet available, online database available. This splash screen also checks if the desired (not required, but desired) permissions have been granted to the app. While these checks are being made there is visual feedback to the user so that they can see what is happening.
If all is good then the main app activity screen opens.
If the permissions check determines that one of more of the desired permissions has not been granted, the activity show above opens.
The screen for this activity advises the user that some permissions have not been granted. It goes on to explain what each permission is needed for. Finally it explains that clicking the button at the bottom of the screen will prompt them to allow or deny each permission that is desired by the app.
clickRequestPermissions
is the function that is attached to the button at the bottom of the permissions information screen.
I assume I do not need to post all of the XML associated with the activity's layout, but it is android:theme="@style/AppTheme.NoActionBar"
activity.
You can create SplashScreenActivity check permission first, later receiver result you can start your Activity.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have developed a simple REST api using NODE and EXPRESSAnd I already have a web-app(browser) and a native mobile application
I try to use this script to block returning visitor only, but the result this script block all visitorPlease anybody help me to fix this script
I have the following code in a Laravel 54 Blade view:
Need to show some messages from hook_block_view