1

アプリケーションのアクティビティで利用可能なすべてのインテント エクストラを取得できるかどうかを知りたいです。gmail アカウントと Google ドライブ フォルダを選択して、ファイルをアップロードする Google ドライブ アクティビティに明示的な意図を与える Android アプリケーションを実行しています。

ユーザーではなく、アプリケーションでフォルダーとアカウントを選択する必要があります (ユーザーは、使用可能なフォルダーとアカウントを簡単に選択できますが、それは望ましくありません)。

それを行うためにインテントにどのエクストラを追加できるかを見ていましたが、Google ドライブのアクティビティと「相互作用」する独自のエクストラはエクストラ EXTRA_STREAM であり、アップロードするファイルのストリームを提供します: http:/ /developer.android.com/reference/android/content/Intent.html#EXTRA_STREAM

また、インテントのすべてのエクストラを含むマップ (バンドル) を返すメソッド、intent.getExtras() が存在することもわかりますが、使用可能なものではなく、以前に追加されたすべてのエクストラがあります。

Google ドライブのアクティビティと相互作用する標準的なエクストラは見つかりませんが、おそらくアプリケーションのソース コードでは、これを行うためにエクストラが定義されています (残念ながら、Google ドライブ アプリケーションはオープン ソースではありません)。

これが今のところのコードです:

public class MainActivity extends Activity {

public final static String EXTRA_MESSAGE = "MESSAGE";


  private void error(String message){
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
  }


public void sendMessage(View view){
    PackageManager pm = this.getPackageManager();
    Intent intent = new Intent(Intent.ACTION_SEND);

   intent.setType("text/plain");
   String rootPath = Environment.getExternalStorageDirectory().getPath();
   intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(rootPath.concat("/rev.txt")));
   intent.putExtra(Intent.EXTRA_SUBJECT, "asunto");
   intent.putExtra(Intent.EXTRA_TEXT, "text");
   String[] emails = new String[4];
   emails[0] = "aa@gmail.com";
   intent.putExtra(Intent.EXTRA_EMAIL, emails);

    List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);

    System.out.println(apps.size());


    if (apps.size()>0) {

        ResolveInfo ri;
        for (Iterator<ResolveInfo> it = apps.iterator(); it.hasNext(); ) {
            ri = it.next();
            System.out.println(ri.toString());
        }
        ComponentName component = new ComponentName("com.google.android.apps.docs",
                "com.google.android.apps.docs.shareitem.UploadSharedItemActivity");

        intent.setComponent(component);

        try {
            startActivity(intent);
        }
        catch (ActivityNotFoundException e) {
            System.out.println("NON ATOPO O DRIVE");
            error("NON ATOPO O DRIVE");
        }
    }
    else {
        System.out.println("non hai aplicacions");
        error("non hai aplicacions");
    }

  }
}
4

1 に答える 1

0

アプリケーションのアクティビティで利用可能なすべてのインテント エクストラを取得できるかどうかを知りたいです。

問題のアクティビティの作成者が提供するドキュメントをお読みください。そのような文書がない場合は、活動を開始しないでください。

サポートされているエクストラに関する情報をプログラムで収集できると期待している場合、それは不可能です。

于 2012-10-29T20:50:07.033 に答える