Skip to content

Instantly share code, notes, and snippets.

View thinzaroo's full-sized avatar

Thinzar Najma thinzaroo

View GitHub Profile
@thinzaroo
thinzaroo / webViewLoading
Created August 25, 2014 04:04
Android WebView Progressbar
WebView webView = (WebView)findViewById(R.id.webview);
String url = "";
ProgressDialog dialog = new ProgressDialog(this);
webView.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) {
dialog.setMessage("Loading");
dialog.show();
@thinzaroo
thinzaroo / AndroidManifest.xml
Created August 18, 2014 14:46
Setting Action Bar background color (appcompat) support all versions
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.actionbartest2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
@thinzaroo
thinzaroo / copyAssetsToSDCard.java
Created June 17, 2014 07:50
Copy files from Android's assets folder to external storage (We will put some defaults files in /Assets folder, copy to /data/data/PACKAGE_NAME/images folder at runtime. And later, if new files available, the app will download images and replace to data/data folder)
private void copyAssets() {
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list("img");
} catch (IOException e) {
Log.e("tag", "Failed to get asset file list.", e);
}
for(String filename : files) {
@thinzaroo
thinzaroo / ImageDownloadAndSave.java
Created June 17, 2014 07:11
This code will download image from URL and save to persistent data folder/SD card using AsyncTask - downloadImagesToSdCard will download image from a web server - onPostExecute will set Image to ImageView, and set as background image of a LinearLayout
private class ImageDownloadAndSave extends AsyncTask<String, Void, Bitmap>
{
String img_URL = "http://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Google.png/320px-Google.png";
String sdCardPath;
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(MainActivity.this);