Android Intentジャンプ送信モーメンツ
5850 ワード
前に書く
2016年7月にはほとんどのdeeplink URL Schemeをマイクロ封筒に入れたが、現在はdeeplinkを通じて直接微信にジャンプして対応する操作を実行することはほとんどできないが、SDKを統合してインタフェースを取得することを望んでいないことが多い.従来の直接Intentを用いて対応するactionを調整して関連操作を実行してみました.
問題の原因:
ネット上には多くの関連チュートリアルがありますが、私のところでテスト使用中に問題が発生しました.例えば、文字・画像を微信の友达まで送ることができます.これは問題ありませんが、写真を友达の輪に送りたいのですが、直接この操作をするのは難しいことに気づきました.微信を逆コンパイルして得たmanifestファイルを見ることで、モーメンツに送信されたActivityはimage/*タイプのファイルしか受け付けていないことがわかりました.ローカルピクチャやネットワークピクチャを公開しようとすると、content//タイプのURIしか認識できません.また、URIを対応するURIに変換すると、対応するピクチャリソースが得られません.愚かな方法を使うしかありません.
具体的な方法:
1.生成した画像を画像としてライブラリ2に保存する.画像情報の更新をシステムに通知する.ライブラリ内の対応画像のURIを取得し、微信対応activity 4を起動する.モーメンツの公開
具体的な方法はコードを参照してください.
関連ツールクラス:
成功した使用方法を共有します.支払宝掃コード支払(開発者への寄付に使用可能) を呼び出す.
qq的deepLink
あなたに役に立つことを願っていますgithubhttps://github.com/panyunyi97】
2016年7月にはほとんどのdeeplink URL Schemeをマイクロ封筒に入れたが、現在はdeeplinkを通じて直接微信にジャンプして対応する操作を実行することはほとんどできないが、SDKを統合してインタフェースを取得することを望んでいないことが多い.従来の直接Intentを用いて対応するactionを調整して関連操作を実行してみました.
問題の原因:
ネット上には多くの関連チュートリアルがありますが、私のところでテスト使用中に問題が発生しました.例えば、文字・画像を微信の友达まで送ることができます.これは問題ありませんが、写真を友达の輪に送りたいのですが、直接この操作をするのは難しいことに気づきました.微信を逆コンパイルして得たmanifestファイルを見ることで、モーメンツに送信されたActivityはimage/*タイプのファイルしか受け付けていないことがわかりました.ローカルピクチャやネットワークピクチャを公開しようとすると、content//タイプのURIしか認識できません.また、URIを対応するURIに変換すると、対応するピクチャリソースが得られません.愚かな方法を使うしかありません.
具体的な方法:
1.生成した画像を画像としてライブラリ2に保存する.画像情報の更新をシステムに通知する.ライブラリ内の対応画像のURIを取得し、微信対応activity 4を起動する.モーメンツの公開
具体的な方法はコードを参照してください.
Resources res=getResources();
Bitmap bmp= BitmapFactory.decodeResource(res, R.drawable.main_activity_list_1);
String filePrefix= null;
try {
filePrefix = saveImageToGallery(this,bmp);
} catch (IOException e) {
e.printStackTrace();
}
ComponentName comp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");
intent.setComponent(comp);
intent.putExtra(Intent.EXTRA_SUBJECT, " ");
intent.putExtra(Intent.EXTRA_TEXT, " ");
intent.putExtra(Intent.EXTRA_TITLE, " ");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri=Uri.parse(filePrefix);
Log.i("uri", "" + uri.getScheme());
intent.setAction(Intent.ACTION_SEND);
intent.setType("image");
Log.i("image", " " + uri);
//
//// ArrayList imageUris = new ArrayList<>();
//// imageUris.add(uri);
//
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
関連ツールクラス:
public static String saveImageToGallery(Context context, Bitmap bmp) throws IOException {
//
File appDir = new File(Environment.getExternalStorageDirectory(), "Boohee");
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = System.currentTimeMillis()+".jpg";
String fileNameTemp;
File file = new File(appDir, fileName);
file.createNewFile();
try {
FileOutputStream fos = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//
try {
fileNameTemp=MediaStore.Images.Media.insertImage(context.getContentResolver(),
file.getAbsolutePath(), fileName, null);
} catch (FileNotFoundException e) {
e.printStackTrace();
fileNameTemp="";
}
//
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse(Environment.getExternalStorageDirectory().toString()+"/Boohee")));
return fileNameTemp;// content://
}
成功した使用方法を共有します.
Uri uriPay = Uri.parse("alipayqr://platformapi/startapp?saId=10000007&qrcode= ");
intent = new Intent(Intent.ACTION_VIEW, uriPay);
qq的deepLink
//String url = "mqqwpa://im/chat?chat_type=group&uin=463028**3&version=1";// qq
String url="mqqwpa://im/chat?chat_type=wpa&uin=XXXXXXXX";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));//
あなたに役に立つことを願っていますgithubhttps://github.com/panyunyi97】