Toast mostly visible in bottom of screen. In bottom if we have any design then that toast will appear in front of our design. It's very irritating and annoying. so, Here i gave solution for that.
Toast toast = Toast.makeText(test.this,"www.arunkumarpd.blogspot.com", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
Hai friends My name is arunkumar and I'm working as an android developer.I'm gonna blog my journey through android world right here...I hope it will be helpful for anyone who's in the same journey...and i also want you to help me to improve the quality of this blog if you are an experienced Android developer...
Tuesday, July 30, 2013
Tuesday, May 21, 2013
Display the path of selected Picture in gallery
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Gallery click = (Gallery) findViewById(R.id.gallery);
final List<String> sdcard = ReadSDCard();
click.setAdapter(new ImageAdapter(this, sdcard));
click.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,
View v, int position, long id) {
Toast.makeText(Galleryy.this,
(CharSequence)sdcard.get(position),
Toast.LENGTH_LONG).show();
}
});
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Gallery click = (Gallery) findViewById(R.id.gallery);
final List<String> sdcard = ReadSDCard();
click.setAdapter(new ImageAdapter(this, sdcard));
click.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,
View v, int position, long id) {
Toast.makeText(Galleryy.this,
(CharSequence)sdcard.get(position),
Toast.LENGTH_LONG).show();
}
});
}
Friday, April 12, 2013
Disable screen lock in android
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
androidmanifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
Simple Alert Popup with Title, Message, Icon and Button
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Title");
alertDialog.setMessage("Message");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Add your code for the button here.
} });
// Set the Icon for the Dialog
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
alertDialog.setTitle("Title");
alertDialog.setMessage("Message");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Add your code for the button here.
} });
// Set the Icon for the Dialog
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
Android- Embed Google Map in Web View
package com.example.androidwebmap;
import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class TestActivity extends Activity {
WebView myWebView;
String mapPath = "https://maps.google.com/?ll=37.0625,-95.677068&spn=29.301969,56.513672&t=h&z=4";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(R.id.mapview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl(mapPath);
}
}
XML File
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Important:
- Permission of "android.permission.INTERNET" is need.
import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class TestActivity extends Activity {
WebView myWebView;
String mapPath = "https://maps.google.com/?ll=37.0625,-95.677068&spn=29.301969,56.513672&t=h&z=4";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView)findViewById(R.id.mapview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl(mapPath);
}
}
XML File
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Important:
- Permission of "android.permission.INTERNET" is need.
Wednesday, April 10, 2013
Autostart our application when android device start from bootup
when you power on the device open our application starts.
through receiver we can achieve this one .
Androidmenifest.xml
<receiver android:enabled="true" android:name=".Startourapp"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
public class Startourapp extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
through receiver we can achieve this one .
Androidmenifest.xml
<receiver android:enabled="true" android:name=".Startourapp"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Startourapp.class
public class Startourapp extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
Tuesday, March 26, 2013
Subscribe to:
Posts (Atom)

