2016-10-15 6 views
-2

나는 안드로이드 개발의 초보자입니다. 이것은 내 애플 리케이션에 대한 내 코드입니다. 버튼을 초기화하고 앱 의도를 이메일로 보내려고했지만 작동하지 않습니다. 아래에 파일을 공유했습니다. 도와주세요.버튼이 이메일 의도를 실행하지 않습니다.

안드로이드 매니페스트

<activity android:name=".ordernow" android:label="Order Details"> 
    <intent-filter> 
     <action android:name="android.intent.action.SENDTO" /> 
     <data android:scheme="mailto" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter> 

</activity> 

activity_ordernow.xml 레이아웃은

<Button 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:textAllCaps="true" 
    android:id="@+id/email_form" 
    android:text="Get Quote" 
    android:onClick="getQuote" /> 

Ordernow.java는

public void getQuote (View view){ 

     String addresses = "[email protected]"; 
     String subject = "Get Quote Online"; 
     String body = "This is the body text for me"; 

     //Compose email to send to Intraline 
     Intent intent = new Intent(Intent.ACTION_SENDTO); 
     //For only email apps to handle the information Also Experiment about using whatsapp 
     intent.setData(Uri.parse("mailto:")); 
     intent.putExtra(Intent.EXTRA_EMAIL, addresses); 
     intent.putExtra(Intent.EXTRA_SUBJECT, subject); 
     intent.putExtra(Intent.EXTRA_TEXT, body); 
     if (intent.resolveActivity(getPackageManager()) != null) { 
      startActivity(intent); 
     } 

} 

나를 qlitch을 찾을 수 있도록 도와주십시오. 정확한 코드 행을 가진 github의 좋은 요지는 설명 외에 설명 될 수 있습니다.

+0

이 ** 자세히 **, 설명하세요, 작동하지 않는다 "는 의미입니다. – CommonsWare

+0

@commonsWare 전자 메일 응용 프로그램이 열리지 않습니다. 앱이 고장났습니다. 오류 : 서페이스 0x7f593eca4200에 EGL_SWAP_BEHAVIOR을 설정하지 못했습니다. 오류 -EGL_SUCCESS 사실 앱은 상태를 변경하지 않고 계속해서 내 활동을 반복 실행합니다. – omukiguy

답변

0

The App breaks down.

앱이 충돌되는 것을 의미하는 경우, use LogCat to examine the Java stack trace associated with the crash.

In fact the app just runs my activity over and over again without changing the status

첫째, ordernow<activity> 요소에서 <intent-filter> 제거. 이 <intent-filter>으로 작성하는 것이 좋을 경우 전자 메일 앱인 경우 적합합니다.

이 시점에서 버튼을 클릭해도 아무런 변화가 없음을 알 수 있습니다. 귀하의 기기에 ACTION_SENDTO (mailto:Uri)을 지원하는 앱이 없음을 나타냅니다. 이메일 클라이언트를 설치하거나 구성해야 작동 할 수 있습니다.

+0

를 제거하면 응용 프로그램이 에뮬레이터 화면에서 Unsupported action 메시지와 충돌합니다. 나는 안드로이드를 실행 중이다. FYI – omukiguy

+0

감사합니다 제거가 매력처럼 작동했습니다. 에뮬레이터에서 메일 상자를 설정해야했습니다. – omukiguy

+0

@omukiguy : 올바른 메일 계정이 설정 될 때까지 일부 메일 앱은 'mailto :'와 같은 활동을 활성화하지 않습니다. 어쨌든, 계정없이,'mailto :'활동은 실제로 아무것도 할 수 없다. – CommonsWare

0

최종 코드는 다음과 같아야합니다.

activity_ordernow.xml 레이아웃

<Button 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:textAllCaps="true" 
    android:id="@+id/email_form" 
    android:text="Get Quote" 
    android:onClick="getQuote" /> 

Ordernow.java이 라이브러리를 사용하는

public void getQuote (View view){ 

     String addresses = "[email protected]"; 
     String subject = "Get Quote Online"; 
     String body = "This is the body text for me"; 

     //Compose email to send to Intraline 
     Intent intent = new Intent(Intent.ACTION_SENDTO); 
     //For only email apps to handle the information Also Experiment about using whatsapp 
     intent.setData(Uri.parse("mailto:")); 
     intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" }); 
     intent.putExtra(Intent.EXTRA_SUBJECT, subject); 
     intent.putExtra(Intent.EXTRA_TEXT, body); 
     if (intent.resolveActivity(getPackageManager()) != null) { 
      startActivity(intent); 
     } 

} 
관련 문제