favicon, screenshot を共有で受け取る

Android標準ブラウザから共有情報、URL, Subject , favicon, screenshot を受け取る。
AndroidManifest.xml にIntent-Filter を以下のように設定する。
mimeType を text/plain で指定しないといけない。

<activity android:name=".SharedRecieveActivity">
   <intent-filter>
       <category android:name="android.intent.category.DEFAULT"/>
       <action android:name="android.intent.action.SEND"/>
       <data android:mimeType="text/plain"/>

   </intent-filter>
</activity>

これで、URLなどのテキストしか受け取れないと思っていたのだが、favicon 画像や、
スクリーンショットの画像も Bitmap で受け取れる。

// URL 受け取り
String url = extras.getString("android.intent.extra.TEXT");
*1.setText(url);

// subject 受け取り
String subject = extras.getString("android.intent.extra.SUBJECT");
*2.setText(subject);


// favicon 受け取り
Bitmap iconBitmap = (Bitmap)extras.get("share_favicon");
*3.setImageBitmap(iconBitmap);

// screenshot 受け取り
Bitmap screenshotBitmap = (Bitmap)extras.get("share_screenshot");
*4.setImageBitmap(screenshotBitmap);

このようにして端末に表示してみると、
screenshot の ImageView の android:layout_width と android:layout_height を
wrap_content にして判るのだが、思ったより受け取った screenshot 画像のサイズが小さい。

f:id:posturan:20160313194239p:plain



この表示の favicon は、32x32dp で表示させてるが、
sacreenshot は、wrap_content を指定している。

*1:TextView)findViewById(R.id.textView1

*2:TextView)findViewById(R.id.textView2

*3:ImageView)findViewById(R.id.imageView1

*4:ImageView)findViewById(R.id.imageView2