2017-10-16 1 views
1

ADBシェルから共有アクティビティを開始します。 ADBシェルからの共有アクティビティの開始

は具体的に私はこの(作業)のjava-スニペットと同じことを達成しようとしています:

adb shell am start -a android.intent.action.SEND -t image/jpeg --es android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg com.snapchat.android --grant-read-uri-permission 

私は現在直面しています問題は、次のとおりです。ここで

File dir = Environment.getExternalStorageDirectory(); 
    File yourFile = new File(dir, "/_tmp/1.jpg"); 

    Uri yourFileUri = Uri.fromFile(yourFile); 

    Intent sendIntent = new Intent(); 
    sendIntent.setAction(Intent.ACTION_SEND); 
    sendIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    sendIntent.setType("image/*"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, yourFileUri); 
    sendIntent.setPackage("com.snapchat.android"); 
    startActivity(sendIntent); 

私が使用していたコマンドですスナップチャットアプリが開いて読み込まれ、1秒間黒く点滅しますが、画像を読み込むことができません。私は間違って何をやっている

adb shell am start -t image/jpeg -d file:///storage/emulated/0/_tmp/1.jpg 

は、私がイメージへのパスは、次のコマンドを発行して作業、およびAndroidのギャラリーで画像を開いていることを確認していますか?

編集:

コマンドを使用:

adb shell am start -a android.intent.action.SEND -t image/jpeg --es android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg com.snapchat.android/com.snapchat.android.LandingPageActivity --grant-read-uri-permission 

が同じ結果を与える、しかし私はDDMSでの実際の呼び出しにそれを比較して、ここでの違いを参照してください。

ログを手動で共有することにより、電話:

10-19 18:01:54.020: D/HtcShareActivity(21561): onItemClick: position=0 activity=com.snapchat.android/com.snapchat.android.LandingPageActivity 

10-19 18:01:54.061: I/ActivityManager(724): START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0x1 cmp=com.snapchat.android/.LandingPageActivity (has clip) (has extras)} from uid 10078 on display 0 

ADBコマンドを使用してログ:

10-19 18:04:29.096: I/ActivityManager(724): START u0 {act=android.intent.action.SEND typ=image/jpeg flg=0x10000000 cmp=com.snapchat.android/.LandingPageActivity (has extras)} from uid 2000 on display 0 

ご覧のとおり、(has clip)はADBコールには存在しません。

それは--grant-read-uri-permissionは「作業」ではないか、少なくとも十分な権限を与えていないことだろうか?

これをテストして最終的に解決するにはどうすればよいですか?

答えて

0

それは私が、私は単にしかし、URIが必要だった、--esを使用して文字列を送信して、任意の実際の画像データを送信するので、私はなかったが判明は--euを使用しているはずです。

次のコマンドを更新:

adb shell am start -a android.intent.action.SEND -t image/jpeg --es android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg com.snapchat.android/com.snapchat.android.LandingPageActivity --grant-read-uri-permission 

へ:

adb shell am start -a android.intent.action.SEND -t image/jpeg --eu android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg com.snapchat.android/com.snapchat.android.LandingPageActivity --grant-read-uri-permission 

は私の問題を解決しました。

@Dusが提案した主な活動の宣言を放棄したわけではありませんでした。 (ただし思考グッド。)

コマンドを実行すると、すべての方法ダウンを簡素化することができる。

adb shell am start -a android.intent.action.SEND -t image/jpeg --eu android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg com.snapchat.android 
+0

あなたのために良い - あなたが望んだことをするコマンドを見つけました。根本原因の分析は間違っています。 '--es'と' --eu'ではなく 'image/*'と 'image/jpeg'の違いがありました。シェルグロブリング(ワイルドカード拡張)は元のコマンドを台無しにしていました。 –

+0

@AlexP。私は '--es'と' --eu'の謎を解決するのに、私がOPでやったコピーとペーストを編集するのを忘れるより多くの時間を無駄にしてくれると確信できます。しかし、私はそれを編集させてください。 – Snowlav

0

あなたが意図を持って、あなたのアプリケーションを開いている、しかし、あなたは活動があなたが近くにちらつきとを参照してください理由である、意図を扱うべきであると宣言していない - の活動は、意図を処理する必要があります。

あなたはMainActivityが意図を扱うことになっていることをいただきました!あなたのコマンドで宣言する必要があります。例えば

FULL_PATH_OF_YOUR_ACTIVITYはマニフェストの主な活動として宣言活動でなければなりません

adb shell am start -a android.intent.action.SEND -t image/* --es 
android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg 
com.snapchat.android/FULL_PATH_OF_YOUR_ACTIVITY 

adb shell am start -a android.intent.action.SEND -t image/* --es 
android.intent.extra.STREAM file:///storage/emulated/0/_tmp/1.jpg 
com.snapchat.android/com.snapchat.android.sub.MainActivity 

サンプルマニフェスト:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.snapchat.android"> 

    <application 
     android:theme="@style/AppTheme"> 
     <activity android:name="com.snapchat.android.sub.MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 
+0

はあなたの応答を親切にありがとうございます。私はそれを通って、自分の発見でOPを編集しました。 – Snowlav

+0

私は最終的に私の問題を解決することができました。あなたの応答が主な問題に直接対処していないのに対して、正しい方向へ私を押し込んでくれました。したがって、私はあなたに賞金を授与させていただきます(8時間後)。助けてくれてありがとう。 – Snowlav

関連する問題