2014-11-02 1 views
0

신청서에 인 텐트가 포함 된 이메일을 보내려고합니다. 휴대 전화에서는 정상적으로 작동하지만 내 태블릿에서는 작동하지 않습니다. 다음은 메일 의도 코드 :Android 애플리케이션에서 태블릿으로 전화 작업 중이지만 이메일로 보내기가 의도되었습니다.

mail.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      Intent intent = new Intent(android.content.Intent.ACTION_SEND); 
      intent.setType("text/html"); 
      List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0); 

      if (!resInfo.isEmpty()) { 
       for (ResolveInfo info : resInfo) { 
        if (info.activityInfo.packageName.toLowerCase().contains("email") || info.activityInfo.name.toLowerCase().contains("email")) { 
         intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
         intent.setPackage(info.activityInfo.packageName); 
         startActivity(Intent.createChooser(intent, "")); 
        } 
       } 
      } 
     } 
    }); 

그리고 이것은 전화를위한 나의 레이아웃입니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
    <Button 
     android:id="@+id/mail" 
     android:layout_width="150dp" 
     android:layout_height="50dp" 
     android:layout_marginBottom="100dp" 
     android:layout_gravity="center|bottom" 
     android:background="@drawable/bakanadanis_button" 
     android:gravity="center" 
     android:text="Bakana Ulaşın" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textColor="@android:color/white" 
     android:textSize="14dp" /> 

그리고 배치가 600dp 태블릿 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/tab_merkezteskilatibg"> 
    <Button 
     android:id="@+id/mail" 
     android:layout_width="200dp" 
     android:layout_height="50dp" 
     android:layout_marginBottom="200dp" 
     android:layout_gravity="center|bottom" 
     android:background="@drawable/bakanadanis_button" 
     android:gravity="center" 
     android:text="Bakana Ulaşın" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:clickable="false" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:textColor="@android:color/white" 
     android:textSize="18dp" /> 

아무도 w 알아? 문제가있을 수도 있니? 감사.

+0

크래시가 발생하거나 증상이 정확히 무엇입니까? 로그가 있다면 여기에 붙여 넣으십시오. –

+0

나는 어떤 오류 메시지 나 그와 비슷한 것을 얻지 못한다. 태블릿에서는 작동하지 않는다. 나는 단추를 클릭 할 수 있지만 전자 메일 작업을 보내기 위해 작동하지 않는다. 여기서 문제를 발견하지 못했다. –

답변

0

태블릿에 다양한 if 조건에서 테스트중인 모든 조건을 통과하는 이메일 클라이언트 애플리케이션이 있는지 확인하십시오. 각 단계에서 디버그 로그를 배치하고 대상 앱을 시작하는 과정에서 얼마나 멀리 나아가고 있는지 확인하십시오.

+0

이 상황을 어떻게 확인할 수 있으며 그렇지 않은 경우이 문제를 어떻게 해결할 수 있습니까? 내 앱이 태블릿에서 작동해야하기 때문입니다. –

+0

가 내 대답에 대한 정보를 추가했습니다. 디버그 로그를 저장합니다. 어쩌면 if (info.activityInfo.packageName.toLowerCase(). contains ("email") || info.activityInfo.name.toLowerCase(). contains ("email")) {}에서 너무 제한적일 수 있습니다. 이완해야 할 수도 있습니다. 또한 가장 쉬운 방법은 앱 외부에서 이메일 클라이언트를 열 수 있습니까? 예 : Gmail 앱 (또는 이와 유사한 기기)을 수동으로 열고 이메일을 보낼 수 있습니까? 그렇다면, 당신은 당신의 의도를 통해 그것을 발사 할 수 있어야합니다. –

+0

info.activityInfo.packageName.toLowerCase()를 추가 할 때 발생하는 문제를 해결했습니다. contains ("Email") || if 문에 info.activityInfo.name.toLowerCase(). contains ("Email")가 포함됩니다. 고맙습니다. –

관련 문제