I search a lot but can't found any solution. https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_CLEAR_APP_CACHE I tried with two codes but not working.
this is first one:
Intent intent = new Intent();
intent.setAction(ACTION_CLEAR_APP_CACHE);
startActivityForResult(intent,REQUEST_CLEAR_APP_CACHE);
And this is second one:
Intent storageIntent = new Intent();
storageIntent.setAction(ACTION_MANAGE_STORAGE);
startActivity(storageIntent);
this is just open only download folder to free some space.
if anyone have solution please post. Thanks in advance.
Related
I have 2 actvities with a xml each but I don't know how to switch to the second page with a button.
Can someone send me the code for the MainActivitie.java please (for a button)
I currently use the findView and onClick
In your MainActivity use this code:
Intent intent = new Intent(MainActivity.this, Second.java);
startActivity(intent);
Please read about "Intents", I have added some links that will clear your concepts.
Previously asked question
Intent Types
I'm about to launch my first app in a week,and want to know if google play automatically adds the shortcut to the home-screen or is it something if have to do with code. I have question like this but there's nothing about creating shortcut on install.
I launched my app found that Google Play does automatically creates a shortcut on the homescreen and we don't have to do it in our code,although i don't know if it works the same way in Amazon app store. hope this helps someone who is trying to find answer to the same question.
Mohit Madaan's answer was correct. Just don't forget to set duplicate to false otherwise you might have several shortcuts:
addIntent.putExtra("duplicate", false);
put this permission in manifest
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
below for creating the shortcut icon on android Homescreen
private void ShortcutIcon(){
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Test");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);}
I came across this and I hope this helps you. http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/
So I've checked the internet for answers but I'm not finding one's that are useful enough to help with this.
So my intent code to start video through the MainActivity.Java is this:
case R.id.button3:
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(getString(R.string.Focus)), "video/*");
startActivity(Intent.createChooser(intent, "Choose an External Player"));
break;"
I wanted to know how I could automatically load up a subtitle through a URL so I can watch my videos with subtitles.
The external video I use is MX Player.
Any help would be appreciated.
The help page for doing this is at https://sites.google.com/site/mxvpen/api.
You basically add an extra to the intent with the string "subs" and then a parcelable array of subtitle file names.
I used the following code to launch PackageInstallerActivity
ComponentName comp = new ComponentName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");
Intent newIntent = new Intent(Intent.ACTION_VIEW);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newIntent.setComponent(comp);
But in Marshmallow, that's not working.
I found the answer, use Intent.ACTION_INSTALL_PACKAGE instead of Intent.ACTION_VIEW.
But, why does Intent.ACTION_VIEW not work?
Look this link Android Document REQUEST_INSTALL_PACKAGES, If your app is targeting API level higher than 25 you need to hold REQUEST_INSTALL_PACKAGES in order to launch the application installer.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.putExtra("address", "12134567899");
intent.putExtra("sms_body", "See attached picture");
intent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/DCIM/Camera/2011-09-09 12.47.29.jpg"));
intent.setType("image/png");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
i try code like this. if intent start mms compose ui was coming how can i overcome and send automatically
First of all. good luck.
Since MMS isn't supported by the android sdk, you have 2 options:
download the android mms aplication and try to understand what's going on there.
follow this link:
http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html
only thing I found working at the moment....
This feature was designed as a safety feature in Android, please do not try to bypass it. It's there for a reason.
If you absolutly must, have you tried running it on a rooted device? It allows greater access.
try this its worked with me .
use
Uri.fromFile
instead of
Uri.parse
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");
startActivity(sendIntent);