2017-11-29 12 views
0

공유 의도가 있습니다. 사용자는 다른 앱의 이미지, 비디오 및 텍스트를 공유 할 수 있습니다. 사용자가 사용자의 사진 갤러리에서 10 개 이상의 이미지를 선택하지 못하게합니다.Android 사진 갤러리에서 공유 사진 옵션을 변경하려면 어떻게해야하나요?

ShareActivity 내부에서 (sharedMessagesControl)이 함수를 조사했지만 다른 실용적인 솔루션을 확인하고 싶습니다. 활동 화면이 열리기 전에이를 어떻게 확인할 수 있습니까? 사진 갤러리 화면에서 이것을 제어 할 수있는 방법이 있습니까? 어떻게해야합니까?

매니페스트 :

ShareActivity(){ 

    private void sharedMessagesControl() { 

    sharedIntent = getIntent(); 

    try { 
     if ((sharedIntent != null) && (sharedIntent.getType() != null) && 
       ((sharedIntent.getPackage() == null) || (!sharedIntent.getPackage().equals(getPackageName())))) { 

      String receivedType = sharedIntent.getType(); 
      String action = sharedIntent.getAction(); 

      if (action != null && (action.equalsIgnoreCase(Intent.ACTION_SEND_MULTIPLE) || action.equalsIgnoreCase("android.intent.action.SEND_MULTIPLE"))) { 

       ArrayList<Uri> uris = sharedIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); 

       if (uris != null && receivedType.contains("image/")) { 

        if (uris.size() > MAX_IMAGE_MEDIA_LIMIT) { 

         sharedIntent = null; 
         new MyToast(R.string.max_limit_image, MyToast.Length.Short); 
        } 
       } 
      } 
     } 
    } catch (Exception e) { 
     Mylog.printStackTrace(TAG + " shareMessageControl error ", e); 
    } 
} 
+0

무엇을 의도적으로 확인합니까? –

+0

다른 실용적인 솔루션. 내 편집 된 답변을 보시기 바랍니다 – propoLis

+0

갤러리의 의도가 실제로 열리기 전에 갤러리에 10 개 이상의 이미지가 있는지 확인하고 싶다는 의미로 문제가 발생하지 않습니까? –

답변

0

ShareActivity의 onCreate 메서드에서 해당 컨트롤을 해결했습니다.

public class ShareActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState, int count) { 

    if (!sharedMessageControl()) { 
     finishAffinity(); 
     } 
     setContentView(R.layout.share_activity); 
     } 
    } 

     private boolean sharedMessageControl() { 

      sharedIntent = getIntent(); 

      try { 
       if ((sharedIntent != null) && (sharedIntent.getType() != null) && 
         ((sharedIntent.getPackage() == null) || (!sharedIntent.getPackage().equals(getPackageName())))) { 

        String receivedType = sharedIntent.getType(); 
        String action = sharedIntent.getAction(); 

        if (action != null && (action.equalsIgnoreCase(Intent.ACTION_SEND_MULTIPLE) || action.equalsIgnoreCase("android.intent.action.SEND_MULTIPLE"))) { 

         ArrayList<Uri> uris = sharedIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); 

         if (uris != null && receivedType.contains("image/")) { 

          if (uris.size() > MAX_IMAGE_MEDIA_LIMIT) { 

           sharedIntent = null; 
           new MyToast(R.string.max_limit_image, MyToast.Length.Long); 

           return false; 
          } else { 
           return true; 
          } 
         }//image 

        } 
       } 

       return true; 

      } catch (Exception e) { 
       Mylog.printStackTrace(TAG + " sharedMessageControl error ", e); 
       return false; 
      } 
     } 
0

먼저 다른 응용 프로그램에서 데이터를 수신하는 방법에 대한 this을 읽을 필요가 :

여기
<activity 
      android:name=".share.ShareActivity" 
      android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize" 
      android:excludeFromRecents="true" 
      android:launchMode="singleTask" 
      android:screenOrientation="portrait" 
      android:windowSoftInputMode="stateHidden"> 
      <intent-filter> 
       <action android:name="android.intent.action.SEND" /> 
       <action android:name="android.intent.action.SEND_MULTIPLE"/> 
       <category android:name="android.intent.category.DEFAULT" /> 
       <data android:mimeType="image/*" /> 
       <data android:mimeType="text/plain" /> 
       <data android:mimeType="video/*" /> 
      </intent-filter> 
     </activity> 

는 방법이다. 그리고 당신은 별도의 데이터를 처리해야합니다 :

<intent-filter> 
    <action android:name="android.intent.action.SEND" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:mimeType="image/*" /> 
</intent-filter> 

모든 데이터 유형에 대해 별도로 처리해야합니다.

+0

감사합니다, 나는 이것들을 알고 의도를 얻을 수는 있지만 내 질문은 다릅니다 – propoLis

+0

사진 갤러리 화면에서 이것을 제어하는 ​​방법이 있습니까? – propoLis

+0

앱 스플래시 화면을 처음 열면 갤러리 화면이 나타나면 데이터 유형을 확인할 수 있습니다. 활동에서 항상 가능하기 때문입니다. –