Мелодия для определенного друга! Телефон перезагружается, ошибка: не удалось получить информацию об отображении из диспетчера отображения;android.os.DeadObjectException
Привет, ребята, я пытаюсь сделать приложение для рингтона, и пару дней назад задавал вопрос с учетом разрешений, и ваши ответы мне очень помогли. Оригинальный вопрос: приложение вылетает при попытке установить песню как конкретного друга в андроид студии, приложение вылетает на getContentresolver Мне удалось установить мелодию для конкретного друга, используя эту функцию:
public void setFriend(Intent data)
{
if(data != null) {
Uri contactData = data.getData();
String contactId = contactData.getLastPathSegment();
String[] PROJECTION = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER,
};
Cursor localCursor = getContentResolver().query(contactData, PROJECTION, null, null, null);
localCursor.moveToFirst();
//--> use moveToFirst instead of this: localCursor.move(Integer.valueOf(contactId)); /*CONTACT ID NUMBER*/
String contactID = localCursor.getString(localCursor.getColumnIndexOrThrow("_id"));
String contactDisplayName = localCursor.getString(localCursor.getColumnIndexOrThrow("display_name"));
Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contactID);
localCursor.close();
ContentValues localContentValues = new ContentValues();
Uri uri = Uri.parse("android.resource://" + getBaseContext().getPackageName() + "/raw/" + nizModela.get(customAdapter.lastSetAsPosition).getNaziv());
File f = customAdapter.SaveFileOnInternalMemory(uri, customAdapter.lastSetAsPosition, getContentResolver());
localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId);
localContentValues.put(ContactsContract.Data.CUSTOM_RINGTONE, f.getAbsolutePath());
getContentResolver().update(localUri, localContentValues, null, null);
Toast.makeText(this, "Ringtone assigned to: " + contactDisplayName, Toast.LENGTH_LONG).show();
}
}
По результату деятельности:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == PICK_CONTACT)
{
//ako je api nizi od 23 netreba permitioni
this.data = data;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M )
{
int PERMISSION_ALL = 1;
String[] PERMISSIONS = {
//Manifest.permission.READ_CONTACTS,
Manifest.permission.WRITE_CONTACTS,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
};
// Manifest.permission.READ_SMS, Manifest.permission.CAMERA
if(!hasPermissions(this, PERMISSIONS)){
ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
}
else{
setFriend(data);
}
}
else
setFriend(data);
}
if(callbackManager.onActivityResult(requestCode, resultCode, data)) {
return;
}
}
И по запросу разрешение на результат:
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;
switch (requestCode) {
case REQUEST_ID_MULTIPLE_PERMISSIONS: {
Map<String, Integer> perms = new HashMap<>();
// Initialize the map with both permissions
perms.put(Manifest.permission.WRITE_CONTACTS, PackageManager.PERMISSION_GRANTED);
perms.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, 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 (perms.get(Manifest.permission.WRITE_CONTACTS) == PackageManager.PERMISSION_GRANTED
&& perms.get(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,"Permisije dozvoljene ",Toast.LENGTH_SHORT).show();
setFriend(data);
// Log.d(TAG, "sms & location services permission granted");
// process the normal flow
//else any one or both the permissions are not granted
} else {
Toast.makeText(this,"Permisije nisu dozvolje",Toast.LENGTH_SHORT).show();
//permission is denied (this is the first time, when "never ask again" is not checked) so ask again explaining the usage of permission
// // shouldShowRequestPermissionRationale will return true
//show the dialog or snackbar saying its necessary and try again otherwise proceed with setup.
}
}
break;
}
}
Так что дело в том, что когда я запускаю это через отладчик, все идет гладко. Однако, когда я устанавливаю мелодию звонка для конкретного друга и пытаюсь проверить его, когда этот конкретный контакт вызывает меня на моем телефоне, мой телефон перезагружается, и мне удалось обнаружить эту ошибку в мониторе устройства, что-то связано с DISPLAY. Я, честно говоря, понятия не имею, что делать, помогите пожалуйста!!
/DisplayManager: Could not get display information from display manager.
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.hardware.display.IDisplayManager$Stub$Proxy.getDisplayInfo(IDisplayManager.java:265)
at android.hardware.display.DisplayManagerGlobal.getDisplayInfo(DisplayManagerGlobal.java:119)
at android.view.Display.updateDisplayInfoLocked(Display.java:864)
at android.view.Display.getMetrics(Display.java:779)
at com.facebook.acra.CrashTimeDataCollector.toString(:21499)
at com.facebook.acra.CrashTimeDataCollector.getConstantDeviceData(:21230)
at com.facebook.acra.CrashTimeDataCollector.populateConstantDeviceData(:21314)
at com.facebook.acra.CrashTimeDataCollector.gatherCrashData(:21179)
at com.facebook.acra.ErrorReporter.handleExceptionInternal(:4307)
at com.facebook.acra.ErrorReporter.uncaughtExceptionImpl(:4914)
at com.facebook.acra.ErrorReporter.uncaughtException(:4878)
at X.0LG.uncaughtException(:49365)
at X.04b.uncaughtException(:14078)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
09-09 14:07:29.976 17670-17850/? E/DisplayManager: Could not get display information from display manager.
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.hardware.display.IDisplayManager$Stub$Proxy.getDisplayInfo(IDisplayManager.java:265)
at android.hardware.display.DisplayManagerGlobal.getDisplayInfo(DisplayManagerGlobal.java:119)
at android.view.Display.updateDisplayInfoLocked(Display.java:864)
at android.view.Display.updateCachedAppSizeIfNeededLocked(Display.java:888)
at android.view.Display.getWidth(Display.java:562)
at com.facebook.acra.CrashTimeDataCollector.toString(:21501)
at com.facebook.acra.CrashTimeDataCollector.getConstantDeviceData(:21230)
at com.facebook.acra.CrashTimeDataCollector.populateConstantDeviceData(:21314)
at com.facebook.acra.CrashTimeDataCollector.gatherCrashData(:21179)
at com.facebook.acra.ErrorReporter.handleExceptionInternal(:4307)
at com.facebook.acra.ErrorReporter.uncaughtExceptionImpl(:4914)
at com.facebook.acra.ErrorReporter.uncaughtException(:4878)
at X.0LG.uncaughtException(:49365)
at X.04b.uncaughtException(:14078)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
09-09 14:07:29.977 17670-17850/? E/DisplayManager: Could not get display information from display manager.
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.hardware.display.IDisplayManager$Stub$Proxy.getDisplayInfo(IDisplayManager.java:265)
at android.hardware.display.DisplayManagerGlobal.getDisplayInfo(DisplayManagerGlobal.java:119)
at android.view.Display.updateDisplayInfoLocked(Display.java:864)
at android.view.Display.getRefreshRate(Display.java:644)
at com.facebook.acra.CrashTimeDataCollector.toString(:21503)
at com.facebook.acra.CrashTimeDataCollector.getConstantDeviceData(:21230)
at com.facebook.acra.CrashTimeDataCollector.populateConstantDeviceData(:21314)
at com.facebook.acra.CrashTimeDataCollector.gatherCrashData(:21179)
at com.facebook.acra.ErrorReporter.handleExceptionInternal(:4307)
at com.facebook.acra.ErrorReporter.uncaughtExceptionImpl(:4914)
at com.facebook.acra.ErrorReporter.uncaughtException(:4878)
at X.0LG.uncaughtException(:49365)
at X.04b.uncaughtException(:14078)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
1 ответ
Спасибо, я не знаю, какой это может быть услуга, приложение работает нормально, мой телефон перезагружается, когда мне звонит конкретный контакт (которому ранее была назначена определенная мелодия звонка), закрываю ли я свое приложение или нет. Я освобождаю игрока только при разрушении, и пауза при паузе:
@Override
protected void onDestroy() {
super.onDestroy();
if(customAdapter.plejer() != null && customAdapter.plejer().isPlaying())
customAdapter.plejer().release();
}
@Override
protected void onPause() {
super.onPause();
if(customAdapter.plejer() != null && customAdapter.plejer().isPlaying())
customAdapter.plejer().pause();
}
@Override
protected void onStop() {
super.onStop();
/*if(customAdapter.plejer() != null && customAdapter.plejer().isPlaying())
customAdapter.plejer().stop();*/
if(customAdapter.plejer() != null && customAdapter.plejer().isPlaying())
customAdapter.plejer().pause();
}