I created a simple test app where I decode a file path into a Bitmap. But even if the permissions are granted it still gives permission denied into the console.
Here's the main activity code:
public class MainActivity extends AppCompatActivity {
public static final String TAG = "DEBUG_";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageView = findViewById(R.id.image_view);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
imageView.setImageBitmap(BitmapFactory.decodeFile("/storage/emulated/0/DCIM/Camera/IMG_20200118_175558.jpg"));
}
}
}
And here's the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.frakm.imagepickertesting">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Related
This is my part of the fragment where the error is coming:
private void openaccess() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
} else {
CropImage.activity(mainImageURI)
.setGuidelines(CropImageView.Guidelines.ON)
.setAspectRatio(1,1)
.setAutoZoomEnabled(false)
.start((Activity) getContext());
// startActivityForResult(intent, CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE);
}
}
}
And this is the manifest code:
<?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.zub.epiphany_atlantic">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/epip_logo"
android:label="EpiPhany"
android:roundIcon="#drawable/epip_logo"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:label">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".HomeActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegistrationActivity" />
<activity android:name=".ProfileActivity"></activity>
</application>
</manifest>
The error is coming on the .start((Activity) getContext()) side in CropImage. (I have also tried with just getActivity()).
Here is the error:
FATAL EXCEPTION: main
Process: com.example.zub.epiphany_atlantic, PID: 11722
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.zub.epiphany_atlantic/com.theartofdev.edmodo.cropper.CropImageActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2026)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1685)
at android.app.Activity.startActivityForResult(Activity.java:4477)
at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
at android.app.Activity.startActivityForResult(Activity.java:4435)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
at com.theartofdev.edmodo.cropper.CropImage$ActivityBuilder.start(CropImage.java:486)
at com.example.zub.epiphany_atlantic.ProfileFragment.openaccess(ProfileFragment.java:333)
at com.example.zub.epiphany_atlantic.ProfileFragment.access$100(ProfileFragment.java:56)
at com.example.zub.epiphany_atlantic.ProfileFragment$ViewDialog$2.onClick(ProfileFragment.java:213)
at android.view.View.performClick(View.java:6323)
at android.view.View$PerformClick.run(View.java:25122)
at android.os.Handler.handleCallback(Handler.java:869)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:206)
at android.app.ActivityThread.main(ActivityThread.java:6784)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:852)
Please help me what to do here. Seems system cannot find the .ProfileActivity activity from manifest file.
You need to add CropImageActivity to your AndroidManifest.xml
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="#style/Base.Theme.AppCompat"/>
I'm developing an app where I want to get the lat,lng of the user's device.I found that I need Access_Fine_Location permission as well as Access_Coarse_Location, I know that I should ask for them during runtime as well as including them in my AndroidManifest.xml, but the app only asks me for the permission ACCESS_COARSE_LOCATION, and ignores asking about ACCESS_FINE_LOCATION.
Here's my code
private boolean checkAndRequestPermissions(){
int permissionReadContacts = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);
int locationPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
int locationPermission2 =ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
List<String> listPermissionsNeeded = new ArrayList<String>();
if (locationPermission != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.ACCESS_COARSE_LOCATION);
}
if (locationPermission2 != PackageManager.PERMISSION_GRANTED) {
Log.i("addingPerm","addingPerm");
listPermissionsNeeded.add(Manifest.permission.ACCESS_FINE_LOCATION);
}
if (permissionReadContacts != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.READ_CONTACTS);
}
if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),REQUEST_ID_MULTIPLE_PERMISSIONS);
return false;
}
return true;
}
and here's the callback:
#Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
String TAG = "sonder.SplashActivity";
Log.d(TAG, "Permission callback called-------");
switch (requestCode) {
case REQUEST_ID_MULTIPLE_PERMISSIONS: {
Map<String, Integer> perms = new HashMap<String, Integer>();
// Initialize the map with both permissions
perms.put(Manifest.permission.ACCESS_COARSE_LOCATION, PackageManager.PERMISSION_GRANTED);
perms.put(Manifest.permission.ACCESS_FINE_LOCATION, PackageManager.PERMISSION_GRANTED);
perms.put(Manifest.permission.READ_CONTACTS, PackageManager.PERMISSION_GRANTED);
// Fill with actual results from user
if (grantResults.length > 0) {
for (int i = 0; i < permissions.length; i++)
perms.put(permissions[i], grantResults[i]);
// Check for both permissions
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new LocListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
UserData.setLocation(LocListener.getLat() + "," + LocListener.getLon());
Log.i("aaaaaaaaaa", "aaaaaaaaaa");
Log.i("" + LocListener.getLat(), "" + LocListener.getLon());
if (perms.get(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
Log.i("Ahmed", "Ahmed");
Log.d("Permissions", "location services permission granted");
FacebookSdk.sdkInitialize(getApplicationContext());
Thread myThread = new Thread() {
#Override
public void run() {
try {
Log.i("May", "May");
sleep(300);
Intent intent = new Intent(getApplicationContext(), setup_activity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
myThread.start();
} else {
//If permissions are denied
Log.d(TAG, "Location permission not granted ask again");
Intent intent = new Intent(getApplicationContext(), setup_activity.class);
startActivity(intent);
finish();
}
}
}
}
}
}
And here's my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permissions.NETWORK_ACCESS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permissions.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permissions.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.location.gps"
android:required="true"/>
<uses-feature android:name="android.hardware.location.network"
android:required="true"/>
<uses-feature
android:name="android.hardware.location"
android:required="true" />
<application
android:name=".utils.orientation_adj"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:roundIcon="#drawable/icon"
android:theme="#style/AppTheme"
android:largeHeap="true">
<activity
android:name=".home.splashscreen"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".home.main_activity"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity android:name=".drawer.drawer_preferences"></activity>
<activity
android:name=".setup.edit_profile_tags"
android:theme="#style/DialogNoTitle"></activity>
<activity
android:name=".setup.setup_activity"
android:theme="#style/AppTheme">
</activity>
<activity android:name=".setup.backend_test"></activity>
<activity
android:name=".drawer.drawer_view_profile"
android:theme="#style/AppTheme.NoActionBar"></activity>
<activity android:name=".drawer.drawer_settings"
android:theme="#style/Switch"></activity>
<activity android:name=".drawer.drawer_help"></activity>
<activity android:name=".setup.not_available_in_your_country"
android:theme="#style/AppTheme.NoActionBar">
<!--Add intent filter here-->
</activity>
<activity android:name=".setup.readiness"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity android:name=".setup.locationPermission"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<service
android:name=".utils.GenericAccountService"
android:exported="false">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="43a4edcd41e180a4beca5aae4040115cfc1b52fe" />
</application>
Three of your <uses-permission> elements have incorrect permission names. There are no Android SDK permissions that begin with android.permissions (note the s on the end). So, for example, you need to change android.permissions.ACCESS_FINE_LOCATION to android.permission.ACCESS_FINE_LOCATION. You cannot request a runtime permission if the <uses-permission> element is missing or invalid.
I have created simple android studio project with Google maps activity. My problem starts when I try to call mMap.setMyLocationEnabled(true); -> it needs to check permission from manifest, but I have some problem with loading the permission on Manifest.permission.ACCESS_FINE_LOCATION. Cant load it, it's red.
The method:
#Override
public void onMapReady(GoogleMap googleMap)
{
mMap = googleMap;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
} else {
Log.d("mes:", "error");
}
}
My manifest file:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="sei0055.placebook.MapsActivity"
android:label="#string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
try
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {}
I am trying use AsyncTask to extract an image over the internet and display on the RecyclerViewer but I am getting the following error message, which's captured from my Exception in my doInBackground from my RecyclerViewAdapter class:
08-02 00:11:25.608: E/ImageDownload(5753): Download failed: Permission denied (missing INTERNET permission?)
See full version of AsyncTask sub-class below:
class GetImageFromNet extends AsyncTask<String, Void, Bitmap> {
private RVAdapter.PersonViewHolder personViewHolder;
private String url = "http://ia.media-imdb.com/images/M/MV5BNDMyODU3ODk3Ml5BMl5BanBnXkFtZTgwNDc1ODkwNjE#._V1_SX300.jpg";
public GetImageFromNet(RVAdapter.PersonViewHolder personViewHolder){
this.personViewHolder = personViewHolder;
}
protected Bitmap doInBackground(String... params) {
try {
InputStream in = new java.net.URL(url).openStream();
Bitmap bitmap = BitmapFactory.decodeStream(in);
return bitmap;
//NOTE: it is not thread-safe to set the ImageView from inside this method. It must be done in onPostExecute()
} catch (Exception e) {
Log.e("ImageDownload", "Download failed: " + e.getMessage());
}
return null;
}
protected void onPostExecute(Bitmap bitmap) {
if (isCancelled()) {
bitmap = null;
}
personViewHolder.personPhoto.setImageBitmap(bitmap);
}
I have no idea why I am getting above error since I have already added the following permission access in my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<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>
</application>
</manifest>
Please help!
Move your <uses-permission> elements to be immediate children of <manifest>, above your <application> element.
Update your manifest as:-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
</application>
Got myself newly registered on AirPush. I integrated bundle SDK with my App. When I tested it for the first time, I got a couple of impressions. It also shows 2 impressions on dashboard.
Now I am unable to fetch the impressions. Did contact the developer team but to no avail.
My code of MainActivity goes like this :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// MMSDK.initialize(this);
// setup a new adView and initialize an adRequest to it.
setupAirPushAdView();
}
#Override
public void onResume() {
super.onResume();
if ((getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_SMALL) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
try {
if (!appStarted) {
setContentView(R.layout.main);
appStarted = true;
}
} catch (Exception e) {
Toast.makeText(this, e.getMessage() + "\n" + e.getClass().toString() + "\n" + e.getLocalizedMessage() + "\n", Toast.LENGTH_LONG).show();
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
perform();
}
}, 2000);
}
private void perform() {
setContentView(R.layout.app_home);
if (!appStarted) {
// attachAdView();
attachAirPushAdView();
appStarted = true;
}
...
Other Methods :
private void setupAirPushAdView() {
ma = new MA(this, null, false);
airPushAdView = new AdView(this, AdView.BANNER_TYPE_IN_APP_AD, AdView.PLACEMENT_TYPE_INTERSTITIAL, false, false,
AdView.ANIMATION_TYPE_LEFT_TO_RIGHT);
}
private void attachAirPushAdView() {
LinearLayout outerAdLayout = (LinearLayout) findViewById(R.id.externalAdId);
outerAdLayout.addView(airPushAdView);
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="9"/>
<!-- android:theme="#android:style/Theme.DeviceDefault.Light" -->
<!-- android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen" -->
<application android:theme="#style/AppTheme" android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity android:name="MainActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="differential_activity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
</activity>
<activity android:name="integral_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="equation_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<!-- android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor" -->
<!-- for all activities -->
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.gyesa.keanp176500.APPID" android:value="206488" />
<meta-data android:name="com.gyesa.keanp176500.APIKEY" android:value="android*1392147786176500813"/>
<activity android:exported="false" android:name="com.gyesa.keanp176500.AdActivity"
android:configChanges="orientation|screenSize"
android:theme="#android:style/Theme.Translucent" />
<activity android:name="com.gyesa.keanp176500.BrowserActivity"
android:configChanges="orientation|screenSize" />
<activity android:name="com.gyesa.keanp176500.VActivity"
android:configChanges="orientation|screenSize" android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<service android:name="com.gyesa.keanp176500.LService" android:exported="false"></service>
<receiver android:name="com.gyesa.keanp176500.BootReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-feature android:name="android.hardware.microphone" android:required="false" />
</manifest>