On Marshmallow, i fell on this Exception when I add a google account type:
" java.lang.SecurityException: uid 10121 cannot remove accounts of
type: com.google at "
I add the accound using
mAccountManager.addAccount("com.google", null, null, null, activity.this, null, null);
And sometime i need to delete all accounts using
mAccountManager.removeAccount(account, this, null, null);
the app has Admin role, and all permissions is think about:
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
i asked the user for :
Manifest.permission.GET_ACCOUNTS,Manifest.permission.READ_PHONE_STATE,Manifest.permission.WRITE_EXTERNAL_STORAGE
How to delete account managed by google authenticator ...?
all is working well on Lollipop, of course
thanks !
Related
I had an app where I fetched Call Log and Contact List and showed them in a RecyclerView. Everything was going fine up to android-8. Suddenly I found that Names are not showing on an Android-9 Device. Then a debug shows that CACHED_NAME and CACHED_PHOTO_URI are always returning null on andorid-9.
I get NUMBER, DURATION and every other thing very well, only the CACHED_NAME and CACHED_PHOTO_URI are missing.
I have checked the changelog of android-9, handled the calllog permission properly, I'm attaching my permissions from manifest with this question. My app is properly taking runtime permissions too. I also checked it on device's Settings. In addition, my app is also set to Default Phone app.
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
String name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME));
Log.d("tag", "name: " + (name == null ? "null": name));
String date = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DATE));
String duration = cursor.getString(cursor.getColumnIndex(CallLog.Calls.DURATION));
String photoUri = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_PHOTO_URI));
Log.d("tag", "photoUri: " + (photoUri == null ? "null": photoUri));
String subscription_id = cursor.getString(cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_ID));
String subscription_component_name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.PHONE_ACCOUNT_COMPONENT_NAME));
Its working fine on android 8 and below, can anyone tell me where is the problem with android-9?
Please check that if needs RuntimePermission for CALL_LOG GROUP. Because they made some changes on Android-9
first, get contacts from Contacts.Contract and then get name, photo by phone number, or contact Id from the database.
am using following code base to request the permission but it always return 'never ask again'
async requestPermission(request){
try{
const response= await PermissionsAndroid.request('PermissionsAndroid.PERMISSIONS.CAMERA',{
'title': 'Cool Photo App Camera Permission',
'message': 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
})
console.log(response)
}catch(err){
}
this.getcurrentLocation()
}
//Response never_ask_again
I recently faced this issue about LOCATION service permission.
I forgot to add android.permission.ACCESS_FINE_LOCATION in AndroidManifest.xml.
So, I think you also forgot to add
<uses-permission android:name="android.permission.CAMERA" />
in your AndroidManifest.xml
I did clean and rebuild several times and finally started working, somehow the build cache is not properly updating.
Removing tools:node="remove" from AndroidManifest.xml fixed mine.
Replace
<uses-permission tools:node="remove" android:name="android.permission.CAMERA"/>
with
<uses-permission android:name="android.permission.CAMERA"/>
https://github.com/zoontek/react-native-permissions/issues/504#issuecomment-914417383
I am trying to create a basic calling app on Android with PortSip but get an error from the setUser method (error -60098: CreateTransportFailure). I think I've followed all the steps as their sample app, and I've used the same credentials that work with the sample app. I've tried using a different local port (as suggested in another post), but haven't had any success. These are my steps:
context = this.getApplicationContext();
callingSDK = new PortSipSdk();
callingSDK.setOnPortSIPEvent(this);
callingSDK.CreateCallManager(context);
int initStatus = callingSDK.initialize(PortSipEnumDefine.ENUM_TRANSPORT_UDP,
"0.0.0.0", 5771, PortSipEnumDefine.ENUM_LOG_LEVEL_DEBUG, LogPath, 200,
"PortSIP VoIP Calling App", 0, 0, "", "", false);
// initialize returns ECoreErrorNone
callingSDK.setSrtpPolicy(PortSipEnumDefine.ENUM_SRTPPOLICY_NONE);
int licenseStatus = callingSDK.setLicenseKey("PORTSIP_TEST_LICENSE");
// setLicenseKey return ECoreTrialVersionLicenseKey, as expected
int userStatus = callingSDK.setUser(accountName, displayName, authName, password,
domain, server, 5060, "", 0, null, 5060);
Apparently, another factor in this error condition is assuring the app that the appropriate permissions. Adding these to the manifest gets past the issue with setUser.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
So I have a simple Ruby app that uses Rpush to send push notifications to my iphone and my android phone. Right now all it does is sends it to the iphone. I am not sure whether the problem is with my script (i.e. incorrect values for the registration_id, app_name, or auth_key), or whether the problem is how I have my Android app configured.
The relevant part of that code is here (values changed for security - but format/length of keys left untouched to make sure they "look right" to people with experience)
API SETUP/RATIONALE (Sending the notification)
# GCM
app = Rpush::Gcm::App.new
app.name = "MyApp"
app.auth_key = "POfaSyfghilK3l-ueSvRLmbawcRThCWkwmcYGeM"
app.connections = 1
app.save
n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("MyApp")
n.registration_ids = ["derGV80JK-s:APA91bHgerskBnrhHndes947nMKxI116tC3-k-tGd-hT5NzVc8QAWEkvCrMwrvs78RUL8-vvhp2ultoevqzZnn8gsr9t6WDXDYpGfCliqaJzj0XByBgbi0bm-rYufjcxfCc_5lEL381F"]
n.data = { message: "testing!" }
n.save!
Rpush.push
I determined that the name of my app was "MyApp" by looking at my google developer console here and noticing that the "Project Name" of the desired project is "MyApp".
I determined the Auth Key on the same site, by navigating to API & Auth -> Credentials -> API Key and copy/pasting the API key from there.
I determined my device's registration id using this code in the main activity of my Android App:
public static String getDeviceID(Context context) {
final TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "";// + tm.getSimSerialNumber();
androidId = ""
+ android.provider.Settings.Secure.getString(
context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(),
((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
When logged, getDeviceID shows me the registration id that I specified in the above ruby code.
APP SETUP/RATIONALE (Receiving the notification)
First, I set up my Android Manifest to have all the necessary permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.johncorser.myapp.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />
Then, I set up a listener service to react to push notifications:
<service
android:name="com.johncorser.myapp.services.GcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
That class is very simple and looks like this:
public class GcmListenerService extends com.google.android.gms.gcm.GcmListenerService {
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d("push", "From: " + from);
Log.d("push", "Message: " + message);
}
}
I would expect these messages to log out after sending the push notifications. But instead nothing happens (no exceptions thrown on the server or app).
Any one see what I'm doing wrong here?
Why are you using the UUID you generated from the Android Device ID as a registration ID for Google Cloud Messaging?
That's NOT how you get a registration id.
To get a registration ID you have to register with GCM on the device and receive back a registration ID/token, as described in Cloud Messaging for Android Quickstart:
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
In order for the above code to work you need to have a google-services.json configuration file (which is parsed by the com.google.gms.google-services gradle plugin, that you also need) in your app/ directory and you need the gcm_defaultSenderId which is the Project ID (Number) you get from the Google Developers Console.
You can easily generate that file and receive the above details by clicking the button "Get a configuration file" and following the steps mentioned there.
The code to get the registration ID needs to be in an IntentService as described here, and you need to define the service in the AndroidManifest.xml file as outlined here
For GCM to be able to communicate with your app, you also need to define in the manifest file a com.google.android.gms.gcm.GcmReceiver which has an intent filter with an action name "com.google.android.c2dm.intent.RECEIVE" and a category name with your package name. Look here for an example.
Try running the sample here by Google themselves.
https://developers.google.com/cloud-messaging/android/start
https://github.com/googlesamples/google-services/tree/master/android/gcm
I feel like something might just be missing in your manifest file.
Hope that helps.
In case anyone else runs in to this, the problem was that I did not whitelist my IP address on developers.google.com. I now have it set so all IPs are whitelisted, and it works like a charm.
I have a PhoneGap application which immediately sets window.location to be my on-internet site and carries on working from there. The app works great except for the following very strange behaviour.
I'm trying to get a geolocation by calling:
function geoErrorHandler(error) {
console.log("getCurrentPosition failed with error message: " + error.message);
}
function showPosition(position) {
// blah
}
var options = {maximumAge:60000, timeout:5000, enableHighAccuracy:true};
navigator.geolocation.getCurrentPosition(showPosition, geoErrorHander, options);
On iOS it works fine in my PhoneGap app. It also works fine when the page is just loaded in a desktop browser. On my Android PhoneGap app, however, it calls my geoErrorHandler. Which is fine - surely I can find out then what the problem was! Except it calls it with an error which has error.message = "" and error.code = null. Hrhum.
It's doing this on two separate devices and a fair amount of internet searching doesn't seem to reveal anyone else with this behaviour. What am I doing wrong?!
Maybe a permission problem?
Try adding to your manifest ACCESS_COARSE_LOCATION, ACCESS_LOCATION_EXTRA_COMMANDS and ACCESS_FINE_LOCATION permissions
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
http://developer.android.com/reference/android/Manifest.permission.html