In build.gradle ,
defaultConfig{
multiDexEnabled true
dependency
configurations
{
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
}
Android Application Programming
Tips & Tricks
Tuesday, March 28, 2017
Thursday, January 12, 2017
How to resolve org.apache.http does not exist
Error:(6, 23) error: package org.apache.http does not exist
Solution:
If you are using target sdk as 23 add below code in your build.gradle
android{
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
}
Solution:
If you are using target sdk as 23 add below code in your build.gradle
android{
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
}
Saturday, January 2, 2016
Prevent webview from showing "web page not available"
Apply the below Code,
WebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { WebView.loadUrl("file:///android_asset/myerrorpage.html"); } });
Saturday, September 12, 2015
Android Internet Connection checking
private boolean isNetworkConnected()
{
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null)
{
//There are no active networks. return false;
}
else
{
return true;
}
}
The above function will return true only if the device has internet connection otherwise false.
manifest file permissions,
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Wednesday, July 9, 2014
WebView Unicode Support
mWebView.loadDataWithBaseURL(null, "தமிழில் கணினி", "text/html", "utf-8", null);
OR
WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
OR
WebSettings settings = mWebView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
Tuesday, July 8, 2014
Load Image from URL
Use the following code to display the picture in ImageView,
URL url = new URL("http://www.vijaynetwork.com/vijay_top_logo.jpg");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);
URL url = new URL("http://www.vijaynetwork.com/vijay_top_logo.jpg");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);
Wednesday, June 4, 2014
How to open a new layout after button click in android
Use the below code,
Button next = (Button) findViewById(R.id.mybutton1);
next.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), my_activity.class);
startActivityForResult(myIntent, 0);
}
});
Button next = (Button) findViewById(R.id.mybutton1);
next.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), my_activity.class);
startActivityForResult(myIntent, 0);
}
});
Subscribe to:
Posts (Atom)