2017-09-11 18 views
0

안녕하세요 여러분, 벨소리 앱을 만들려고 노력하고 며칠 전에 몇 가지 질문을 사용 권한을 고려해 보았습니다. 당신의 대답이 제게 많은 도움이되었습니다. 원래 질문 :특정 친구를위한 벨소리 !! 전화 재시작, 오류 : 디스플레이 관리자로부터 표시 정보를 가져올 수 없습니다. android.os.DeadObjectException

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; 
      } 
     } 

활동 결과에

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(); 


     } 
    } 

: 나는 특정 친구,이 기능을 사용하여 벨소리를 설정하는 관리 App crashes when trying to set song as specific friend in android studio, app crashes at getContentresolver 따라서 디버거를 통해 모든 것을 원활하게 실행하면됩니다. 그러나 특정 친구를위한 벨소리를 설정하고 시도 할 때 해당 연락처이 내 전화를 걸 때 휴대 전화가 다시 시작되고 장치 모니터에서이 오류을 잡았습니다. 과 관련 있습니다. 디스플레이 .I 정직,! 도와주세요 않습니다 무엇을 아무 생각이 없다 :

/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) 
+0

deadobjectexception가 발생합니다. 사용하기 전에 사용하는 서비스가 살아 있고 호출 가능한지 확인해야합니다. –

답변

0

감사합니다, 나는 그것을 할 수있는 서비스를 모르는, 응용 프로그램이 잘 작동, 내 휴대 전화가 다시 시작 특정 연락처는 이전에이 (저를 호출 할 때 특정 벨소리로 지정됨), 내 앱 종료 여부. 난 단지 파괴에 플레이어를 분리 한 일시에 일시 정지 : 당신은 죽지 않았다 사망하거나 더 이상 존재하지 않은 서비스를 호출 할 때

@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(); 

    } 
+0

갤럭시 s2 인 내 동생의 휴대 전화에서 시험 할 때 한 가지 더. 전화가 다시 시작되기 전에 전화로이 메시지가 표시됩니다. 불행히도 ** process.com.android.phone이 중지되었습니다. ** – Petar