manifest.java :
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mfi;
public final class Manifest {
public static final class permission {
public static final String C2D_MESSAGE="permission.C2D_MESSAGE";
}
}
AndroidManifest.xml :
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BODY_SENSORS"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GPS_PROVIDER" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
But I'm unable to request any permissions from MainActivity as below code throws compiler error L: cannot resolve symbol : ACCESS_FINE_LOCATION
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
1);
How to update manifest.java to generate the permission I'm attempting to access, in this case Manifest.permission.ACCESS_FINE_LOCATION ?
Import the below package for Manifest class,
import android.Manifest;
You can easily access the permission Manifest.permission.ACCESS_FINE_LOCATION and others too
Related
My application is closed immediately after launching due permission request without an errors. This is my code, is here something wrong? Also, I post manifest file here to let you check it. I need bluetooth permission and data access.
The probem is in this line:
ActivityCompat.requestPermissions(this, permissions, REQUEST_MICROPHONE);
If I comment this, application will not close after launching.
private static final int REQUEST_MICROPHONE = 1;
private void askPermissions(){
String[] permissions = {Manifest.permission.RECORD_AUDIO,
Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT};
if (!hasPermissions(permissions)) {
ActivityCompat.requestPermissions(this, permissions, REQUEST_MICROPHONE);
}
}
private boolean hasPermissions(String[] permissions) {
if(permissions != null){
for(String perm : permissions){
if(ContextCompat.checkSelfPermission(this, perm) != PackageManager.PERMISSION_GRANTED)
return false;
}}
return true;
}
And the Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="30"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<!-- If you want to declare that your app is available to BLE-capable devices only, include the following in your app's manifest:/-->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:configChanges="orientation|screenSize"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:screenOrientation="portrait"
android:theme="#style/Theme.myapp">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.myapp.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It was discrepancy between Android version and way to get permissions. Unfortunately, it was not any errors or other communications and I have to find a problem by luck.
I'm working with GeckoView and met problem with installing AddOns. As suggested on Documentation, I've provided XPI compatible with Android, but nothing changes. Copying file to Assets doesn't make a change. Browser doesn't acknowledge WebExtension.
private fun setupGeckoView() {
geckoSession?.permissionDelegate = object : GeckoSession.PermissionDelegate {
override fun onContentPermissionRequest(
session: GeckoSession,
perm: GeckoSession.PermissionDelegate.ContentPermission
): GeckoResult<Int>? {
return super.onContentPermissionRequest(session, perm)
}
}
geckoView = findViewById(R.id.geckoView)
val runtime = GeckoRuntime.create(this)
runtime.settings.consoleOutputEnabled = true
runtime.webExtensionController.promptDelegate = PromptListener(runtime.webExtensionController)
runtime.webExtensionController
.install("https://addons.mozilla.org/android/downloads/file/3719055/youtube_high_definition-85.0.0-an+fx.xpi")
geckoSession.open(runtime)
geckoView.setSession(geckoSession)
geckoSession.loadUri("https://www.youtube.com")
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gv.webapp">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<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/Theme.webapp">
<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>
<!--<provider
android:authorities="com.gv.webapp"
android:name="com.gv.webapp.Provider">
<grant-uri-permission android:path="string"
android:pathPattern="string"
android:pathPrefix="string" />
</provider>-->
</application>
</manifest>
I'm checking logs and the result is confusing. I've got prompt that WebExtension is installed, but when I looking at controller.list() it's empty.
You may be missing a PermissionDelegate:
geckoSession?.permissionDelegate = object : GeckoSession.PermissionDelegate {
override fun onContentPermissionRequest(
session: GeckoSession,
perm: GeckoSession.PermissionDelegate.ContentPermission
): GeckoResult<Int>? {
return super.onContentPermissionRequest(session, perm)
}
}
Permission delegate allows you to handle requests from Gecko for any permission that needs handling.
I added android:process in manifest file, and then i get app has stopped popup while loading up apk. Service doesn't load but the rest of thing is running okay.
<service
android:name=".smsReceiveService"
android:exported="true"
android:enabled="true"
android:process=":myProcess"
android:isolatedProcess="true"
android:permission="android.permission.RECEIVE_SMS" />
add permission in manifiest file at top
like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ncrypted.otp">
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"/>
than your receiver sevrcice in application tag like this
<receiver android:name=".SmsReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
than handle run time permision for lolipop virsions like this
private void requestSmsPermission() {
String permission = Manifest.permission.READ_SMS;
int grant = ContextCompat.checkSelfPermission(this, permission);
if (grant != PackageManager.PERMISSION_GRANTED) {
String[] permission_list = new String[1];
permission_list[0] = permission;
ActivityCompat.requestPermissions(this, permission_list, 1);
}
}
I am trying to connect my android application to parse.com but I am stuck at last step.On Parse website it is mentioned Add the following to your ApplicationonCreate():
Parse.enableLocalDatastore(this);
Parse.initialize(this, "yDdwwIjw0jmTnTEAzc3CQaXXXXXXXXXXXX", "kljfnAt3XXXXXXXXXXXX");
I am unable to understand how and where to add this code.Please guide through the steps.
Create Application class inside main package
public class MyApplication extends Application{
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, getString(R.string.parse_app_id), getString(R.string.parse_client_key));
}
}
Add permissions to your Manifest file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Create a class which extends the Application class
public class MyApp extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, getString(R.string.parse_application_id), getString(R.string.parse_client_key));
}
}
Don't forget to add android:name=".MyApp" to the application in your Manifest file.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:name=".MyApp" >
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I am successfully calling my first Activity from my AIR Native Extension, however, when I try to call the second one, I am getting the Permission Denial error (see logcat screenshot). I have tried everything I have found suggested on this site, so posting question.
02-12 15:43:22.430: I/ActivityManager(271): START {act=android.intent.action.RUN cmp=com.cno.android.map/.AddMarkerActivity (has extras) u=0} from pid 14173
02-12 15:43:22.440: W/ActivityManager(271): Permission Denial: starting Intent { act=android.intent.action.RUN cmp=com.cno.android.map/.AddMarkerActivity (has extras) } from ProcessRecord{4147a718 14173:air.TestAndroidExtension.debug/u0a75} (pid=14173, uid=10075) not exported from uid 10072
Here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cno.android.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- End of copy. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<activity
android:name="com.cno.android.map.InitMapActivity"
android:label="#string/title_activity_init_map" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.cno.android.map.AddMarkerActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.RUN"/>
</intent-filter>
</activity>
</application>
Things to note:
I first tried AddMarkerActivity without any intent-filter defined. Not having ANY luck, I began experimenting with the RUN action. I have commented everything out in AddMarkerActivity except for one logcat message that says "HELLO" in the onCreate method. As you can see my Activity is not duplicated in the manifest and exported is set to true.
And finally, here is how I am calling the Activity:
public class AddAnnotationFunction implements FREFunction {
public static final String TAG = "AddAnnotationFunction";
public final static String EXTRA_MARKER = "com.cno.nativemap.functions.marker";
#Override
public FREObject call(FREContext context, FREObject[] args) {
Intent intent = new Intent();
intent.setClassName("com.cno.android.map", "com.cno.android.map.AddMarkerActivity");
Log.d(TAG, "Starting Map Activity- add marker");
intent.setAction("android.intent.action.RUN");
intent.putExtra(EXTRA_MARKER, new GeoMarker(args));
context.getActivity().startActivity(intent);
return null;
}
}