Friday, June 5, 2015

ANDROID - How to change package name for project (For all files)


Most of the time I face the problem related to change/rename/refracter package name for Android projects.

If you want to change your package name for project then follow following steps.

Note: Don't need to change all package name. change only main package and keep it other same.

1. right click on perticular package - > Refracter - > Rename -> Set new package name (OK)
2. right click on project -> Android Tools -> Rename Application Package -> Set new package name (OK)
3. Open AndroidMenifest.xml file and search old package name and if available then manually replace with new one
4. Use main "Search" option for finding the old package name and replace it with new one.




Wednesday, June 25, 2014

Handling javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

Handling javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
>Only use for debugging purpose, Don't use for production.

Step 1:
DefaultHttpClient httpClient = (DefaultHttpClient) getNewHttpClient();

Step 2:
public HttpClient getNewHttpClient() {
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore
.getDefaultType());
trustStore.load(null, null);

SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
registry.register(new Scheme("https", sf, 443));

ClientConnectionManager ccm = new ThreadSafeClientConnManager(
params, registry);

return new DefaultHttpClient(ccm, params);
} catch (Exception e) {
return new DefaultHttpClient();
}
}

Thursday, August 29, 2013

How to set link on phone number and email addresses available in TextView. Or How to use Linkify

Reference from : http://android-developers.blogspot.hu/2008/03/linkify-your-text.html

TextView tvDesc = (TextView) findViewById(R.id.tv_desc_data);
tvDesc.setText(details);
Linkify.addLinks(tvDesc, Linkify.ALL);


If we use Linkify.ALL then all phone numbers and emails in textview default set blue links(called hyperlink).
And when user click on this link automatically open call dialed pad or email box.

Wednesday, June 12, 2013