How can I get my Android device Internal Download Folder path? [duplicate]

If a device has an SD card, you use: Environment.getExternalStorageState() If you don’t have an SD card, you use: Environment.getDataDirectory() If there is no SD card, you can create your own directory on the device locally. //if there is no SD card, create new directory objects to make directory on device if (Environment.getExternalStorageState() == null) … Read more

How to display image with WebView loaddata?

It is possible to embedd the base64 encoded imagedata direct into the <img>-tag: <img src=”data:image/jpeg;base64,base64DataHere” /> Here an example for creating the <img>-tag (I use an byte-array instead the String for raw-data, because in my tests an String as source didn’t work – I assume that String can’t handle binary-data): byte[] imageRaw = yourImage; String … Read more

Eclipse will not recognize project as library (ActionBarSherlock/ViewPagerIndicator)

Where to store the actual library project does not matter, as long as you use a relative link to reference it. Check out the Library Projects – Development considerations: Library project storage location There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as … Read more

call activity method from broadcast receiver

Thanks @Manishika. To elaborate, making the Broadcastreceiver dynamic, instead of defining it in the manifest, did the trick. So in my broadcast receiver class, i add the code : MainActivity main = null; void setMainActivityHandler(MainActivity main){ this.main=main; } In the end of the onReceive function of the BroadcastReceiver class, I call the main activity’s function … Read more

How can I get the JSON response of a POST request in a WebView?

You should override the shouldOverrideUrlLoading method of WebViewClient @Override public boolean shouldOverrideUrlLoading (WebView view, String url) { if(flag) { URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); // read inputstream to get the json.. … … return true; } return false } @override public void onPageFinished (WebView view, String … Read more

How to list all files and folders locating on sd card

It seems that when you touch Back dispatchKeyEvent() receive twice the KeyEvent KEYCODE_BACK, so I suggest you do it this way : public class FileList extends ListActivity { private File file; private List<String> myList; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myList = new ArrayList<String>(); String root_sd = Environment.getExternalStorageDirectory().toString(); file = new File( root_sd + “/external_sd” … Read more

SecurityException with grantUriPermission when sharing a file with FileProvider

Well, after a week and a lot of trial and error, it seems the answer is to not specify permissions. So the App A Manifest should instead contain: <provider android:name=”android.support.v4.content.FileProvider” android:authorities=”au.com.example.AppA.fileprovider” android:exported=”false” android:grantUriPermissions=”true” > <meta-data android:name=”android.support.FILE_PROVIDER_PATHS” android:resource=”@xml/filepaths” /> </provider> ie, I removed the read and write permissions. My initial understanding, and failing to find documentation … Read more

android Google Play Warning: SSL Error Handler Vulnerability

To properly handle SSL certificate validation, change your code to invoke SslErrorHandler.proceed() whenever the certificate presented by the server meets your expectations, and invoke SslErrorHandler.cancel() otherwise. For example, I add an alert dialog to make user have confirmed and seems Google no longer shows warning. @Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) … Read more

How can I make Android Volley perform HTTPS request, using a certificate self-signed by an Unknown CA?

i have implemented https by creating new requestQueue in my volley class by the following code public RequestQueue getRequestQueue() { if (mRequestQueue == null) { mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new HurlStack(null, newSslSocketFactory())); } return mRequestQueue; } private SSLSocketFactory newSslSocketFactory() { try { // Get an instance of the Bouncy Castle KeyStore format KeyStore trusted = KeyStore.getInstance(“BKS”); … Read more

How to access device settings programmatically?

Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1); But you need root access to do this. Only system apps have permission to change secure settings Edit: Try this to Show all ANRs Settings.Secure.putInt(ContentResolver,Settings.Secure.ANR_SHOW_BACKGROUND,0); and for Don’t keep activities ActivityManagerNative.getDefault().setAlwaysFinish(true) but ActivityManagerNative is hidden in standard api set. you will need to do either reflection or use this method to get android.jar. … Read more