30 lines
953 B
Java
30 lines
953 B
Java
|
package net.crystalyx.setaswallpaper;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.content.Intent;
|
||
|
import android.net.Uri;
|
||
|
import android.os.Bundle;
|
||
|
|
||
|
public class SetWallpaperActivity extends Activity {
|
||
|
|
||
|
@Override
|
||
|
protected void onCreate(Bundle savedInstanceState) {
|
||
|
super.onCreate(savedInstanceState);
|
||
|
|
||
|
Intent intent = getIntent();
|
||
|
if (Intent.ACTION_SEND.equals(intent.getAction())) {
|
||
|
launchWallpaperActivity(intent.getParcelableExtra(Intent.EXTRA_STREAM), intent.getType());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void launchWallpaperActivity(Uri uri, String mimeType) {
|
||
|
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
|
||
|
intent.addCategory(Intent.CATEGORY_DEFAULT);
|
||
|
intent.setDataAndType(uri, mimeType);
|
||
|
intent.putExtra("mimeType", mimeType);
|
||
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||
|
startActivity(Intent.createChooser(intent, "Set as:"));
|
||
|
}
|
||
|
|
||
|
}
|