ThisimageistheGooglePhotosgalleryapplication,inthetop3pointsthereisamenuofoptions(PHOTOBELOW):
Onceyouclickon"use as" the following options appear:
Iwasabletomakemyapplicationappearinthis"set as"
<activity android:name=".Main.SetWpfora">
<intent-filter>
<action android:name="android.intent.action.ATTACH_DATA" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
My problem is how do I get this attach_data / image in my activity?
I did something similar, but instead use:
<action android:name="android.intent.action.ATTACH_DATA" />
I used <action android:name="android.intent.action.SEND" />
but the send is for sharing, I wanted something more specific so I tried to use attach_data, with the send I was able to get the image my main activity looked like this:
public class SetWpfora extends AppCompatActivity {
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_wpfora);
imageView = findViewById(R.id.imageVisualizer);
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
}
}
public void handleSendImage(Intent intent) {
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
Picasso.with(getApplicationContext())
.load(imageUri)
.into(imageView);
}
}
}