Gmail's new compose now default

Posted by Unknown Kamis, 28 Maret 2013 0 komentar


You are busy people, so it's no surprise that an overwhelming number of you opted to try out Gmail's faster, simpler compose experience after it launched last October. In addition to telling us what you love about the new compose experience (like how much easier it is to multitask!) you’ve also been sending us helpful suggestions for what features you'd like to see added. As a result of your input, we're now ready to introduce the new compose experience as the default for everyone. We're looking forward to hearing what you think!

If you're already using the the new compose experience, you've probably noticed it's gotten a lot of upgrades over the last few months, from a new way to send files with Google Drive to much-requested features like pop-out replies. We’ve also added support for originally missing features like starring and labeling when composing and the Canned Responses lab.

The new compose will be rolling out to everyone over the next few days. You can learn more in our help center, or follow us on Google+, where we'll be posting more tips for using the new compose.



Baca Selengkapnya ....

Indic Languages in Gmail on your feature phone

Posted by Unknown Rabu, 27 Maret 2013 0 komentar


Indian culture is diverse, with more than 100 languages and thousands of alphabets used every day. Depending on where you are, you might hear anything from Gujarati to Bengali and Tamil to Urdu. If you're a speaker of these languages and use a feature phone, communicating is about to get a little easier.

Starting today, we are rolling out support for 6 Indic languages in Gmail on the feature phone browser: Bengali, Gujarati, Kannada, Marathi, Tamil, and Telugu. Simply go to settings in Gmail and choose your language.

Some 500 million new users from around the world will join the Internet between now and 2015. Since most will experience the web for the first time on a mobile device, it’s important that people everywhere can communicate in the language they know best.




Baca Selengkapnya ....

Get inside your favorite movies with Google Play

Posted by Unknown 0 komentar
“What’s his name again? Wasn’t he the guy in that movie with the battle of the bands?” Now, while you're watching a movie on Google Play, you can find out that it’s Jack Black (of course!), who was born in Hermosa Beach and is 43 years old. And with one click you can search the web and learn the fun fact that his parents are both rocket scientists.

We’ve added info cards to the Google Play Movies & TV app so you can easily learn more about the actors, related films and even what song is playing in many of your favorite movies. When you’re watching a film on your tablet, simply press pause and cards will pop up with information about actors on screen. You can tap on an actor’s face to learn more about him, like his age, place of birth, his character in the movie, and his recent work, or scroll through the info cards to learn more about the movie or soundtrack. When you resume the movie, the cards will disappear.


This new feature is offered for hundreds of movies in Google Play and we’re adding more every day. If you’re in the U.S. and have a tablet running Android 4.0 (Ice Cream Sandwich) and higher, download the latest version of the Google Play Movies & TV app to check it out. We hope to bring info cards to more movies in more countries and devices soon.

Posted by Ben Serridge, Product Manager for Google Play

Baca Selengkapnya ....

The World’s Languages in Your Pocket (No Internet Required)

Posted by Unknown 0 komentar
Have you ever found yourself in a foreign country, wishing you knew how to say "I'm lost!" or "I'm allergic to peanuts”? The Internet and services like Google Translate can help—but what if you don't have a connection? 

Today we're launching offline language packages for Google Translate on Android (2.3 and above) with support for fifty languages, from French and Spanish to Chinese and Arabic. 

You can select [Offline Languages] in the app menu to see all the offline language packages available for download. To enable offline translation between any two languages, you just need to select them in the offline languages menu. Once the packages are downloaded, you're good to go.

 

While the offline models are less comprehensive than their online equivalents, they are perfect for translating in a pinch when you are traveling abroad with poor reception or without mobile data access.
  

So go out and explore another language or another culture without worrying about Internet access. There’s a whole world offline out there.

Posted by Minqi Jiang, Associate Product Manager

Baca Selengkapnya ....

Restrict Edittext input content using Input Filters in ANDROID

Posted by Unknown Jumat, 22 Maret 2013 0 komentar

InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
// TODO Auto-generated method stub
for (int i = start; i < end; i++) {
if (Character.isLetter(source.charAt(i))) {
System.out.println("Input consist of only characters from 'a' to 'z'");
return "";
}
}
return null;
} };
edit.setFilters(new InputFilter[]{filter});
Here the filters will check whether the input content has only characters from 'a' to 'z'.
same way use the condition below to have characters from'a' to 'z' and '0' to '9' and avoid special characters.

Character.isLetterOrDigit(source.charAt(i))


Baca Selengkapnya ....

Simple AutoComplete TextView in ANDROID

Posted by Unknown 0 komentar

public class Autocomplete extends Activity {
String name[]={
"John", "Angel", "Mark", "Angelina",
"Jhony", "Juli", "Augustine", "Robert",
"Reena", "Ancilina", "Mary", "Juliet"
};
AutoCompleteTextView autotextview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_autocomplete);

autotextview=(AutoCompleteTextView) findViewById(R.id.myautocomplete);
autotextview.setAdapter(new ArrayAdapter<string>(this, android.R.layout.simple_dropdown_item_1line, name));

}

Baca Selengkapnya ....

Google Keep--Save what’s on your mind

Posted by Unknown Rabu, 20 Maret 2013 0 komentar
Every day we all see, hear or think of things we need to remember. Usually we grab a pad of sticky-notes, scribble a reminder and put it on the desk, the fridge or the relevant page of a magazine. Unfortunately, if you’re like me you probably often discover that the desk, fridge or magazine wasn’t such a clever place to leave the note after all...it’s rarely where you need it when you need it.

To solve this problem we’ve created Google Keep. With Keep you can quickly jot ideas down when you think of them and even include checklists and photos to keep track of what’s important to you. Your notes are safely stored in Google Drive and synced to all your devices so you can always have them at hand.

If it’s more convenient to speak than to type that’s fine—Keep transcribes voice memos for you automatically. There’s super-fast search to find what you’re looking for and when you’re finished with a note you can archive or delete it.


Changing priorities isn’t a problem: just open Keep on your Android phone or tablet (there’s a widget so you can have Keep front and center all the time) and drag your notes around to reflect what matters. You can choose the color for each note too.

Pro tip: for adding thoughts quickly without unlocking your device there's a lock screen widget (on devices running Android 4.2+).



Google Keep is available on Google Play for devices running Android 4.0, Ice Cream Sandwich and above. You can access, edit and create new notes on the web at http://drive.google.com/keep and in the coming weeks you'll be able to do the same directly from Google Drive.

Posted by Katherine Kuan, Software Engineer

Baca Selengkapnya ....

Get Id of inflated xml in ANDROID

Posted by Unknown Selasa, 19 Maret 2013 0 komentar
How to inflate an xml see my previous post.
Suppose we have button in the inflated xml we can get the id like this:
 Button b1= (Button) v1.findViewById(R.id.button1); 
//where v1 is the View

Baca Selengkapnya ....

View Flipper with Animationin ANDROID

Posted by Unknown 0 komentar
Suppose you have to show an item for few minutes and then flips to next one we can use viewflipper. ViewFlipper inherits from frame layout, so it displays a single view at a time. in java class:
   ViewFlipper vflip;
vflip=(ViewFlipper) findViewById(R.id.viewFlipper1);
//when a view is displayed
vflip.setInAnimation(this,android.R.anim.fade_in);
//when a view disappears
vflip.setOutAnimation(this, android.R.anim.fade_out);
vflip.setFlipInterval(500);
vflip.startFlipping();//starts flippin
// vflip.stopFlipping();//stops flipping
in xml
<RelativeLayout 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" >

<ViewFlipper
android:id="@+id/viewFlipper1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:layout_marginTop="85dp"
android:layout_toLeftOf="@+id/textView1" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/images1" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/images2" />

<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/images3" />

<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/images4" />

</ViewFlipper>
</RelativeLayout>
Here the view changes for every 500 millisecond.same way we can even provide layouts inside it.

Baca Selengkapnya ....

Latest Chrome Beta for Android reduces data usage by half

Posted by Unknown Kamis, 14 Maret 2013 0 komentar
The last time we reported about Chrome Beta for Android we were excited to show how Google’s popular browser can be modified to render pages in full-screen mode. This time, users with heavy mobile data usage are in for a treat: Chrome 26 Beta adds a new experimental feature that makes use of Google’s proxy servers to optimize web content, thereby saving bandwidth.
The reduction in data usage is made possible by Google’s utilization of its own proxy servers, which phones running Chrome mobile establish a connection with and transmit HTTP requests. The proxy servers then pass on the request to the target resource, performs content optimization, and finally sends back a lighter load to the phones.

read more:
http://www.androidauthority.com/latest-chrome-beta-android-reduces-data-usage-half-165262/

Baca Selengkapnya ....

BlackBerry plans security feature for Android, iPhone

Posted by Unknown 0 komentar
BlackBerry will offer technology to separate and make secure both work and personal data on mobile devices powered by Google Inc's Android platform and by Apple Inc's iOS operating system, the company said on Thursday.
The new feature could help BlackBerry sell high-margin services to enterprise clients even if many, or all, of their workers are using smartphones made by BlackBerry's competitors. That may be crucial for the company as it has lost a vast amount of market share to the iPhone and to Android devices, such as Samsung Electronics Co's Galaxy line.
Jefferies analyst Peter Misek said he expects BlackBerry's device management software to gain traction this year, and boost revenue next year.

read more:
http://www.financialexpress.com/news/blackberry-plans-security-feature-for-android-iphone/1088255

Baca Selengkapnya ....

Open wifi settings in android

Posted by Unknown 0 komentar


final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.settings","com.android.settings.wifi.WifiSettings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity( intent); 

Baca Selengkapnya ....

Check different Network status in Android

Posted by Unknown Rabu, 13 Maret 2013 0 komentar

public class CheckConnectionsDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
checkAvailableConnection();
}

void checkAvailableConnection()
{
ConnectivityManager connMgr = (ConnectivityManager)
this.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

final android.net.NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if( wifi.isAvailable() )
{ Toast.makeText(this, "Wifi Available" ,Toast.LENGTH_LONG).show();
}
else if( mobile.isAvailable() )
{ Toast.makeText(this, "3G Available" ,Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "No Network Available" ,Toast.LENGTH_LONG).show();
}
}
}

Baca Selengkapnya ....

Programatically enable or disable WIFI in android

Posted by Unknown 0 komentar
simple code snippet to enable WI-FI in android programatically in android.
public boolean enableWIFI()
{
WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
if(wifiManager.isWifiEnabled())
{
if(wifiManager.setWifiEnabled(false))
return true;
}
else {
if(wifiManager.setWifiEnabled(true))
return true;
}
return false;
}
Make sure that you add the permissions:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE">

Baca Selengkapnya ....

How to enable and disable Wifi in ANDROID?

Posted by Unknown 0 komentar

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(enabled);

Baca Selengkapnya ....

Sniper Vs Sniper: Online v1.1.8 apk

Posted by Unknown 0 komentar


IMGA'S EXCELLENCE IN CONNECTIVITY AWARD!
Go Head-to-Head against other Snipers from all around the world.

Online mode for real-time Sniper operations
Team up with other Sniper in Alliance Attack mode for counter terrorist operation
Online ranking
Online chatting with other Snipers in the world
Upgradable weaponry
6 High quality maps
30 Special Missions
────────────────
OTHER FUN and EXCITING GAMES BY COM2US
────────────────
< Tiny Farm > An entire world, right here in your very own hands
< Homerun Battle 2 > Become The Homerun LEGEND!!
< 9 Innings: 2013 Pro Baseball > The Ultimate Baseball game!
< Derby Days > Most Fabulous Horse game on mobile
< Inotia4 > Finest of Inotia series, Best RPG Ever!
< Tower Defense > The One and only Tower Defense!
< Aqua Story > Your very own mobile Aquarium
< Ovenbreak > Run Gingerman Run!
< Slice It! > Once you start Slicing, YOU CAN'T STOP!
< The World of Magic > A magic world of full-featured MMORPG!
< Minigame Paradise > World of delight right at the tip of your fingers!
< Puzzle Family > Action and excitement in 8 delightful puzzle games
Other fun and exciting games are available, too!
────────────────
PLAY WITH Com2uS!!
────────────────
TO REQUEST MORE APPS AND GAMES EMAIL ME :- saxenak96@gmail.com
please support us by clicking +1 button . 
THANKS:- KARAN . (O_o)



Baca Selengkapnya ....

Using external font in ANDROID

Posted by Unknown Selasa, 12 Maret 2013 0 komentar
    

TextView text =(TextView) findViewById(R.id.textview);
Typeface face;
face = Typeface.createFromAsset(getAssets(), "AMAZB.TTF");
text.setTypeface(face);
text.setTextSize(30);
text.setTextColor(Color.WHITE);

Baca Selengkapnya ....

Inflate an xml in ANDROID

Posted by Unknown 0 komentar
  RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.relative);
//create a view to inflate the layout_item (
the xml with the textView created before)
View view = getLayoutInflater().inflate(R.layout.inflate,mainLayout,false);
//add the view to the main layout
mainLayout.addView(view);

                         

Baca Selengkapnya ....

SQLiteManager plugin for Eclipse

Posted by Unknown 0 komentar

See more basics on Android along with interview questions


How can we access the database?i will give solution to all these problems. I created the database from my previous post

You can see the sqlite database in eclipse by opening File Explorer .Then

/data/data/package_name/databases

But here we cannot see the tables and table data.

For viewing the table details Eclipse has a plugin. You can download the jar from below.
          download jar

Now put the jar in the folder
eclipse/dropins/
and restart the eclipse and now you can see the sqlitemanager plugin on the top right of the File Explorer window

reference link :
http://www.coderzheaven.com/2011/04/18/sqlitemanager-plugin-for-eclipse/


Baca Selengkapnya ....

Merge two layouts in xml

Posted by Unknown 0 komentar
In any one of the xml include the other xml like this :

<include layout="@layout/newxmlname"/>

Baca Selengkapnya ....

A complete reference to Database Helper Class in SQLite in ANDROID

Posted by Unknown 0 komentar
For COMPLETE TUTORIALS see here :
DABASEHELPER CLASS :

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBAdapter
{
public static final String KEY_ROWID = "id";
public static final String KEY_NAME = "title";
public static final String KEY_NICKNAME = "duedate";
private static final String DATABASE_NAME = "assinDB.db";
private static final String DATABASE_TABLE = "assignments";
private static final int DATABASE_VERSION = 2;


private final Context context;
private DatabaseHelper ObjectDBHelper;
private SQLiteDatabase db;

public DBAdapter(Context ctx) {
context = ctx;
}

private static class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}

@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub

db.execSQL("CREATE TABLE IF not exists " + DATABASE_TABLE
+ " ("+ KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ KEY_NAME + " TEXT NOT NULL, " +
KEY_NICKNAME+ " TEXT NOT NULL);");
}

@Override
public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion)
{
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
}
}

// =====================open database================
public DBAdapter open() throws SQLException {
ObjectDBHelper = new DatabaseHelper(context);
db = ObjectDBHelper.getWritableDatabase();
return this;
}

// =========close database==================
public void close() {
ObjectDBHelper.close();
}

//==enter fields in from SQLiteExample database====
public void entryfield(String namestr, String nickstr) {
ContentValues cv = new ContentValues(); // Bundle for writting the database fields
cv.put(KEY_NAME, namestr); // put the values passed to ContentValues
cv.put(KEY_NICKNAME, nickstr); // put the values passed to ContentValues
db.insert(DATABASE_TABLE, null, cv); //insert into databse with vlues as "content vales"
}

//===========getting all data==============
public String getdata() {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME };
Cursor c = db.query(DATABASE_TABLE, coloumns, null, null,null, null, null);
// basically reading a database need cursor
String result = " "; // since string is to be returned
System.out.println("count of cursor=====>>" +c.getCount());
int iRowid = c.getColumnIndex(KEY_ROWID);
// calling each row values
int iRowName = c.getColumnIndex(KEY_NAME);
int iRowNickName = c.getColumnIndex(KEY_NICKNAME);
if (c.moveToFirst()) {
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {
result = result + c.getString(iRowid) + " "+ c.getString(iRowName) + " "
+ c.getString(iRowNickName) + "\n";
System.out.println(result + " <> " + iRowid + " <> " +
iRowName);
c.moveToNext();
}
}
c.close();
db.close();
return result;
}

// ==================== get info ===================
public String returnName(long l) {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME };
// calling elements in an array

Cursor c = db.query(DATABASE_TABLE, coloumns, KEY_ROWID + "=" + l,null, null, null, null);
if (c != null) {
c.moveToFirst();
String name = c.getString(1);
// since name is in position 1 ie second coloumn
return name;
}
return null;
}

public String returnickname(long l) {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME }; //calling elements in an array
Cursor c = db.query(DATABASE_TABLE, coloumns,KEY_ROWID + "=" + l, null, null, null, null);
if (c != null) {
c.moveToFirst();
String nickname = c.getString(2);
// since name is in position 2 ie 3rd coloumn
return nickname;
}
return null;
}
// ==================== edit ===================
public void updateentry(long smodify, String namestr, String nickstr) {
// TODO Auto-generated method stub
ContentValues cvupdate = new ContentValues(); // Bundle for writting the database fields
cvupdate.put(KEY_NAME, namestr); // put the values passed to ContentValues
cvupdate.put(KEY_NICKNAME, nickstr); // put the values passed to ContentValues
db.update(DATABASE_TABLE, cvupdate, KEY_ROWID + "="+ smodify, null); // specify where to be changed

}

// ==================== delete ===================
public void deleteentry(long ldelete) {
// TODO Auto-generated method stub
db.delete(DATABASE_TABLE, KEY_ROWID + "="
+ ldelete, null);
} }


Baca Selengkapnya ....

Get a single record from SQLite in ANDROID

Posted by Unknown 0 komentar
For COMPLETE TUTORIALS see here :
in DATABASE HELPER class:

String[] coloumns = new String[] { KEY_ROWID, KEY_NAME, KEY_NICKNAME };
// calling elements in an array
Cursor c = db.query(DATABASE_TABLE, coloumns, KEY_ROWID + "=" + l,null, null, null, null);
if (c != null)
{
c.moveToFirst();
String name = c.getString(1);
// since name is in position 1 ie second coloumn
return name;
}
return null;
in sqlite.java :

String s =editinfo.getText().toString();
long l=Long.parseLong(s);
DBAdapter adapter=new DBAdapter(SQliteExample.this);
adapter.open();
String returnedname=adapter.returnName(l);
String returnednickname=adapter.returnickname(l);
adapter.close();
editName.setText(returnedname);
editNickName.setText(returnednickname);

Baca Selengkapnya ....

Get all records from SQLite in ANDROID

Posted by Unknown Senin, 11 Maret 2013 0 komentar
For COMPLETE TUTORIALS see here :
in DABASEHELPER CLASS :

String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME }; // calling all elements in an array
Cursor c = db.query(DATABASE_TABLE, coloumns, null, null, null, null,null);// basically reading a database need cursor
String result = " ";// since string is to be returned
System.out.println("count of cursor=====>>" + c.getCount());

int iRowid = c.getColumnIndex(KEY_ROWID);
// calling each row values
int iRowName = c.getColumnIndex(KEY_NAME);
int iRowNickName = c.getColumnIndex(KEY_NICKNAME);

if (c.moveToFirst()) {
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {result
= result + c.getString(iRowid) + " "
+ c.getString(iRowName) + " "
+ c.getString(iRowNickName) + "\n";
System.out.println(result + " <> " + iRowid + " <> "+ iRowName);
c.moveToNext();
}
}
c.close();
db.close();
return result;
in sqlite.java :

TextView infotext=(TextView) findViewById(R.id.tvsqlinfo);
DBAdapter info = new DBAdapter(this);
info.open();
String data =info.getdata();
System.out.println("result is ==========>>" + data);
info.close();
infotext.setText(data);
infotext.setTextColor(Color.RED);

Baca Selengkapnya ....

Modify records in SQLite in ANDROID

Posted by Unknown 0 komentar
For COMPLETE TUTORIALS see here :
in DABASEHELPER CLASS :

ContentValues cvupdate = new ContentValues(); // Bundle for writting the database fields
cvupdate.put(KEY_NAME, namestr);// put the values passed to ContentValues
cvupdate.put(KEY_NICKNAME, nickstr);// put the values passed to ContentValues
db.update(DATABASE_TABLE, cvupdate, KEY_ROWID + "=" + smodify, null);// specify where to be changed
in sqlite.java :

String Namestr = editName.getText().toString();
String Nickstr = editNickName.getText().toString();
String smodify =editinfo.getText().toString();
long lmodify =Long.parseLong(smodify);
DBAdapter adaptmodify =new DBAdapter(SQliteExample.this);
adaptmodify.open();
adaptmodify.updateentry(lmodify,Namestr,Nickstr); // pass index and new values to be inserted
adaptmodify.close();

Baca Selengkapnya ....

Delete records from SQLite table in ANDROID

Posted by Unknown 0 komentar
For COMPLETE TUTORIALS see here :
in DABASEHELPER CLASS :

public void deleteentry(long ldelete)
{
// TODO Auto-generated method stub
db.delete(DATABASE_TABLE, KEY_ROWID + "=" +ldelete, null);
}
in Sqlite.java :

String sdelete =editinfo.getText().toString();
long ldelete =Long.parseLong(sdelete);
DBAdapter adaptdelete =new DBAdapter(SQliteExample.this);
adaptdelete.open();
adaptdelete.deleteentry(ldelete); //pass the index to be deleted
adaptdelete.close();

Baca Selengkapnya ....

Insert records in SQLite tables in ANDROID

Posted by Unknown 0 komentar
For COMPLETE TUTORIAL see here :

in DABASEHELPER CLASS :

public void entryfield(String namestr, String nickstr) {
ContentValues cv = new ContentValues(); // Bundle for writting the database fields
cv.put(KEY_NAME, namestr);// put the values passed to ContentValues
cv.put(KEY_NICKNAME, nickstr);// put the values passed to ContentValues
db.insert(DATABASE_TABLE, null, cv);// insert into databse with vlues as "content vales"
}
in sqlite.java

//==Create an object of adapter class to call methods==
DBAdapter Entryadapter = new DBAdapter(SQliteExample.this);
Entryadapter.open();
Entryadapter.entryfield(Namestr,Nickstr); // Calling the function in DBAdapter Class
Entryadapter.close();

Baca Selengkapnya ....

Simple SQLite Example in Android

Posted by Unknown 0 komentar

See more basics on Android along with interview questions

DBAdapter.java (DABASEHELPER CLASS)

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBAdapter
{
public static final String KEY_ROWID = "id";
public static final String KEY_NAME = "title";
public static final String KEY_NICKNAME = "duedate";
private static final String DATABASE_NAME = "assinDB.db";
private static final String DATABASE_TABLE = "assignments";
private static final int DATABASE_VERSION = 2;

private final Context context;
private DatabaseHelper ObjectDBHelper;
private SQLiteDatabase db;

public DBAdapter(Context ctx) {
context = ctx;
}

private static class DatabaseHelper extends SQLiteOpenHelper {
public DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null,DATABASE_VERSION);
// TODO Auto-generated constructor stub
}

@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub

db.execSQL("CREATE TABLE IF not exists " + DATABASE_TABLE + " ("
+ KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ KEY_NAME + " TEXT NOT NULL, "
+ KEY_NICKNAME+ " TEXT NOT NULL);");
}

@Override
public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion)
{
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
}
}

// =====================open database================
public DBAdapter open() throws SQLException {
ObjectDBHelper = new DatabaseHelper(context);
db = ObjectDBHelper.getWritableDatabase();
return this;
}

// =========close database==================
public void close() {
ObjectDBHelper.close();
}

//==enter fields in from SQLiteExample database====
public void entryfield(String namestr, String nickstr) {
ContentValues cv = new ContentValues(); // Bundle for writting the database fields
cv.put(KEY_NAME, namestr); // put the values passed ContentValues
cv.put(KEY_NICKNAME, nickstr); // put the values passed to ContentValues
db.insert(DATABASE_TABLE, null, cv); //insert into databse with vlues as "content vales"
}

//===========getting all data==============
public String getdata() {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME };
Cursor c = db.query(DATABASE_TABLE, coloumns, null, null, null, null, null);
// basically reading a database need cursor
String result = " "; // since string is to be returned
System.out.println("count of cursor=====>>"+c.getCount());
int iRowid = c.getColumnIndex(KEY_ROWID); // calling each row values
int iRowName = c.getColumnIndex(KEY_NAME);
int iRowNickName = c.getColumnIndex(KEY_NICKNAME);
if (c.moveToFirst()) {
c.moveToFirst();
for (int i = 0; i < c.getCount(); i++) {
result = result + c.getString(iRowid) + " "
+ c.getString(iRowName) + " "
+ c.getString(iRowNickName) + "\n";
System.out.println(result + " <> " + iRowid + " <> " +
iRowName);
c.moveToNext();
}
}
c.close();
db.close();
return result;
}

// ==================== get info ===================
public String returnName(long l) {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME,KEY_NICKNAME };
// calling elements in an array
Cursor c = db.query(DATABASE_TABLE, coloumns, KEY_ROWID +"=" + l,null, null, null, null);
if (c != null) {
c.moveToFirst();
String name = c.getString(1);
// since name is in position 1 ie second coloumn
return name;
}
return null;
}

public String returnickname(long l) {
// TODO Auto-generated method stub
String[] coloumns = new String[] { KEY_ROWID, KEY_NAME, KEY_NICKNAME };//calling elements in an array
Cursor c = db.query(DATABASE_TABLE, coloumns,KEY_ROWID + "=" + l, null, null, null, null);
if (c != null) {
c.moveToFirst();
String nickname = c.getString(2); // since name is in position 2 ie 3rd coloumn
return nickname;
}
return null;
}
// ==================== edit ===================
public void updateentry(long smodify, String namestr, String nickstr) {
// TODO Auto-generated method stub
ContentValues cvupdate = new ContentValues(); // Bundle for writting the database fields
cvupdate.put(KEY_NAME, namestr); // put the values passed to ContentValues
cvupdate.put(KEY_NICKNAME, nickstr); // put the values passed to ContentValues
db.update(DATABASE_TABLE, cvupdate, KEY_ROWID + "=" + smodify, null);// specify where to be changed
}

// ==================== delete ===================
public void deleteentry(long ldelete) {
// TODO Auto-generated method stub
db.delete(DATABASE_TABLE, KEY_ROWID + "=" + ldelete, null);
} }
SQliteexample.java

public class SQliteExample extends Activity
{
Button butupdate,butview,butgetinfo,butedit,butdelete;
EditText editName,editNickName,editinfo;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

butupdate=(Button) findViewById(R.id.button1);
butview=(Button) findViewById(R.id.button2);
butgetinfo=(Button) findViewById(R.id.button3);
butedit=(Button) findViewById(R.id.button4);
butdelete=(Button) findViewById(R.id.button5);
editName=(EditText) findViewById(R.id.editText1);
editNickName=(EditText) findViewById(R.id.editText2);
editinfo=(EditText) findViewById(R.id.editText3);

butupdate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
boolean diditwork=true;
try {
String Namestr = editName.getText().toString();
String Nickstr = editNickName.getText().toString();

//==Create an object of adapter class to call methods==
DBAdapter Entryadapter = new DBAdapter(SQliteExample.this);
Entryadapter.open();
Entryadapter.entryfield(Namestr,Nickstr); //Calling the function in DBAdapter class
Entryadapter.close();
}
//Exception handling
catch (Exception e) {
diditwork=false;
String error=e.toString();
Dialog dialog=new Dialog(SQliteExample.this);
dialog.setTitle("Exception !!!");
TextView tv= new TextView(SQliteExample.this);
tv.setText(error);
dialog.setContentView(tv);
dialog.show();
}
finally
{
if(diditwork)
{
Dialog dialog=new Dialog(SQliteExample.this);
dialog.setTitle("Created !!!");
TextView tv= new TextView(SQliteExample.this);
tv.setText("Sucess");
dialog.setContentView(tv);
dialog.show();
}
}
}
});
butview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(SQliteExample.this,SqlView.class);
startActivity(intent);

}
});

butgetinfo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String s =editinfo.getText().toString();
long l=Long.parseLong(s);
DBAdapter adapter=new DBAdapter(SQliteExample.this);
adapter.open();
String returnedname=adapter.returnName(l);
String returnednickname=adapter.returnickname(l);
adapter.close();
editName.setText(returnedname);
editNickName.setText(returnednickname);
}
});
butedit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String Namestr = editName.getText().toString();
String Nickstr = editNickName.getText().toString();
String smodify =editinfo.getText().toString();
long lmodify =Long.parseLong(smodify);
DBAdapter adaptmodify =new DBAdapter(SQliteExample.this);
adaptmodify.open();
adaptmodify.updateentry(lmodify,Namestr,Nickstr);
adaptmodify.close();
}
});
butdelete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String sdelete =editinfo.getText().toString();
long ldelete =Long.parseLong(sdelete);
DBAdapter adaptdelete =new DBAdapter(SQliteExample.this);
adaptdelete.open();
adaptdelete.deleteentry(ldelete);
adaptdelete.close();
}
});
} }


SqliView.java

public class SqlView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sqlview);
TextView infotext=(TextView)findViewById(R.id.tvsqlinfo);
DBAdapter info = new DBAdapter(this);
info.open();
String data =info.getdata();
System.out.println("result is ==========>>" + data);
info.close();
infotext.setText(data);
infotext.setTextColor(Color.RED);
} }

Baca Selengkapnya ....

Poweramp Full Version Unlocker 1.1-build-12 apk (NEEDS ROOT)

Posted by Unknown Kamis, 07 Maret 2013 0 komentar

Music moves people; it unites us, it allows us to relax, and sometimes, when done right, it can even motivate us to do great things. Poweramp does great things.
The #1 paid music player in the Google Play Store 3 years running—Poweramp is the most powerful music player available on the Android OS. Features like gapless play, an unmatched equalization system, great crossfade, and support for most popular music file format might all make Poweramp the best $3.99 you have ever spent in your life—1+ million users would agree to that.
If you have not already, try out the free full trial version. The trial version will give you 15 days of the full, uninterrupted, Poweramp experience. That means you get to experience your music like only Poweramp can offer. If you need a few reasons why to buy the full version of Poweramp, here are two good reasons:
- Get all the future updates for free: Once you purchase Poweramp, all the future updates are free to you as long as you have the Unlocker.
- Have a dedicated music player: Poweramp is dedicated to being the best music player available, and we will never change from that. Poweramp is focus on doing nothing more than being a great music player.

Follow us on Twitter (@Poweramp2) for information about Poweramp and chances to win prizes like Google Play Gift cards, tablets, phones, and more.
Like us on Facebook (https://www.facebook.com/Poweramp.Android) to stay in the loop.
Tell your friends about us to make their music experience better, and so they can also enjoy the #PowerampLifestyle.

==========
***Please update BOTH Unlocker and Poweramp Trial (it's the main app) if you're experiencing any issues with the license.
***Please don't try to update if you purchased Unlocker on Poweramp site, as Google Play Unlocker is not the same. Just keep your current Unlocker as is.
       
INSTRUCTIONS (needs root) :
1.FIRST DOWNLOAD THE FOLLOWING FILES :
Poweramp 2.0.8 build-525 trial from here .
Poweramp Full Version Unlocker 1.1-build-12 apk from here .
lucky patcher from here
2.Install all three
3.open unlocker and select start poweramp .
4.read the message that appears(thanks and all that) , first it will show that failed to verify the licence . don't worry .
5.open lucky patcher and select poweramp .
6.click on open menu of patches .
7.select custom patch .
8.select first patch.
9.then select apply .
10.wait for it to apply patch . and all done . 
11.now you can do whatever you want . 
thanks karan . 
if any link is dead please email me :- saxenak96@gmail.com 
plz click on +1 button . 



Baca Selengkapnya ....

Celebrating Google Play’s first birthday

Posted by Unknown Rabu, 06 Maret 2013 0 komentar
Accessing digital entertainment should be simple, whether you like to read books on your tablet, listen to music on your phone and computer, or watch movies on all three. That’s why one year ago today we launched Google Play, where you can find and enjoy your favorite music, movies, books and apps on your Android phone and tablet, or on the web.

Google Play has grown rapidly in the last year, bringing you more content in more languages and places around the globe. In addition to offering more than 700,000 apps and games, we’ve partneredwith all of the major music companies, movie studios and publishers to bring you the music, movies, TV shows, books and magazines you love. And we’ve added more ways for you to buy them, including paying through your phone bill and gift cards, which we're beginning to roll out in the U.K. this week.

Since no birthday is complete without presents, we’re celebrating with a bunch of special offers across the store on songs, TV shows, movies and books. We’re even offering a collection of games with some fun birthday surprises created by developers.

It’s been a busy year, but we’re just getting started. We look forward to many more years of bringing you the best in entertainment!


Baca Selengkapnya ....

TextView with link in ANDROID…….

Posted by Unknown Senin, 04 Maret 2013 0 komentar
in java class:
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;

public class TextViewLinkDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText( Html.fromHtml("This is a textView with a link " +"
AngelMark Blog "
+ "created in the Java source code using HTML."));
tv.setMovementMethod(LinkMovementMethod.getInstance());
}
}
main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
In Manifest file give internet permission

Baca Selengkapnya ....

Parsing an XML from Online in Android

Posted by Unknown 0 komentar
Create a fresh project and name it ParseXMLDemo
Then in the ParseXMLDemo.java file copy this code
|
import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class ParseXMLDemo extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

ArrayList<String> mylist = new ArrayList<String>();
String xml = ParseXMLMethods.getXML();
Document doc = ParseXMLMethods.XMLfromString(xml);
int numResults = ParseXMLMethods.numResults(doc);

if((numResults <= 0)){
Toast.makeText(ParseXMLDemo.this, "There is no data in the xml file", Toast.LENGTH_LONG).show();
finish();
}

NodeList children = doc.getElementsByTagName("os");
for (int i = 0; i < children.getLength(); i++)
{
HashMap<string string=""> map =new HashMap<string string="">();
Element e = (Element)children.item(i);
map.put("id", ParseXMLMethods.getValue(e, "id"));
map.put("name", ParseXMLMethods.getValue(e, "name"));
map.put("site", ParseXMLMethods.getValue(e, "site"));
mylist.add(map);
}
ListAdapter adapter = new SimpleAdapter(this,mylist ,R .layout.list_layout,
new String[] { "name", "site" },
new int[] { R.id.title, R.id.subtitle});

setListAdapter(adapter);


final ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);
Toast.makeText(ParseXMLDemo.this,o.get("name"), Toast.LENGTH_LONG).show();
}
});
} }

Now create another java file inside the src folder and name it ParseXMLMethods.java and copy this contents into it.
import java.io.IOException;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class ParseXMLMethods {

public final static Document XMLfromString(String xml){

Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
doc = db.parse(is);
}
catch (ParserConfigurationException e) {
System.out.println("XML parse error: " + e.getMessage());
return null;
}
catch (SAXException e) {
System.out.println("Wrong XML file structure: " +e.getMessage());
return null;
}
catch (IOException e) {
System.out.println("I/O exeption: " +e.getMessage());
return null;
}
return doc;
}
public final static String getElementValue( Node elem ) {
Node kid;
if( elem != null){
if (elem.hasChildNodes()){
for( kid = elem.getFirstChild(); kid != null;kid = kid.getNextSibling() ){
if( kid.getNodeType() == Node.TEXT_NODE ){
return kid.getNodeValue();
}
}
}
}
return "";
}
public static String getXML(){
String line = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://new ABC.com/xml/test.xml");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (Exception e) {
line = "Internet Connection Error >> " + e.getMessage();
}
return line;
}

public static int numResults(Document doc)
{
Node results = doc.getDocumentElement();
int res = -1;
try
{
res = Integer.valueOf(results.getAttributes()
.getNamedItem("count").getNodeValue());
}catch(Exception e ){
res = -1;
}
return res;
}

public static String getValue(Element item, String str)
{
NodeList n = item.getElementsByTagName(str);
return ParseXMLMethods.getElementValue(n.item(0));
}
}
in main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FF0000"
android:drawSelectorOnTop="false"/>
</LinearLayout>
list_layout.xml:
< ?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="7dp">
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:textSize="14dp"
android:textColor="#000000"/>
</LinearLayout>
Strings.xml:
<?xml version="1.0" encoding="utf-8"?> 
<resources>
<string name="hello"> Hello World, ParseXMLDemo!</string>
<string name="app_name"> ParseXMLDemo New ABC.com</string>
</resources>

Baca Selengkapnya ....

What are webservices? How we can use in Android?

Posted by Unknown 0 komentar
A web service is any piece of software that makes itself available over the internet and uses a standardized XML messaging system. XML is used to encode all communications to a web service. For example, a client invokes a web service by sending an XML message, then waits for a corresponding XML response. Because all communication is in XML, web services are not tied to any one operating system or programming language–Java can talk with Perl; Windows applications can talk with Unix applications.

Web Services are self-contained, modular, distributed, dynamic applications that can be described, published, located, or invoked over the network to create products, processes, and supply chains. These applications can be local, distributed, or Web-based. Web services are built on top of open standards such as TCP/IP, HTTP, Java, HTML, and XML.

Web services are XML-based information exchange systems that use the Internet for direct application-to-application interaction. These systems can include programs objects, messages, or documents.

A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards.


To summarize, a complete web service is, therefore, any service that:
1. Is available over the Internet or private (intranet) networks
2. Uses a standardized XML messaging system
3. Is not tied to any one operating system or programming language
4. Is self-describing via a common XML grammar
Is discoverable via a simple find mechanism

An Example
Consider a simple account-management and order -processing system. The accounting personnel use a client application built with Visual Basic or JSP to create new accounts and enter new customer orders.

The processing logic for this system is written in Java and resides on a Solaris machine, which also interacts with a database to store the information.
The steps
illustrated above are as follows:

The client program bundles the account registration information into a SOAP message.

This SOAP message is sent to the Web Service as the body of an HTTP POST request.
The Web Service unpacks the SOAP request and converts it into a command that the application can understand. The application processes the information as required and responds with a new unique account number for that customer.

Next, the Web Service packages up the response into another SOAP message, which it sends back to the client program in response to its HTTP request.
The client program unpacks the SOAP message to obtain the results of the account registration process. For further details regarding the implementation of Web Services technology, read about the Cape Clear product set and review the product components.

In Android we can use it like an HTTP call. Several examples can be found on coderzheaven.com
Some of them are “connecting with php and android” where the php script can be called as a webservice which can be used by any system independent of the operating systems.


reference:
http://www.coderzheaven.com/2013/02/26/webservices-android/


Baca Selengkapnya ....

Simple Json Parser in Android

Posted by Unknown Sabtu, 02 Maret 2013 0 komentar
Java Class:private JSONObject jObject;
private String jString = "{\"itemmenu\": {" +
"\"itemid\": \"file\"," +
" \"itemvalue\": \"File\"," +
" \"itemarray\": { \"menuitem\": " +
"[ " + "{\"value\": \"New\" , " +
"\"onclick\": \"CreateNewDoc()\"}, " +
" {\"value\": \"Open\"," +
" \"onclick\":" + " \"OpenDoc()\"}," +
"{\"value\": \"Close\"," +
" \"onclick\": \"CloseDoc()\"}" +
"]}" +
"}" +
"}";

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
parse();
}
catch (Exception e)
{
e.printStackTrace();
} }

private void parse() throws Exception {

//Create json object and use it to retrieve the data in it
jObject = new JSONObject(jString);
JSONObject menuObject = jObject.getJSONObject("itemmenu");
String attributeId = menuObject.getString("itemid");
System.out.println("THE ATTRIBUTE ID IS.....1....."+attributeId);
String attributeValue = menuObject.getString("itemvalue");
System.out.println("THE ATTRIBUTE ID IS.....2....."+attributeValue);
JSONObject popupObject = menuObject.getJSONObject("itemarray");
JSONArray menuitemArray = popupObject.getJSONArray("menuitem");
for (int i = 0; i < 3; i++) {
System.out.println("THE ATTRIBUTE ID IS.....3....."+menuitemArray.getJSONObject(i)
.getString("value").toString());
System.out.println("THE ATTRIBUTE ID IS.....4....."+menuitemArray.getJSONObject(i)
.getString("onclick").toString());
} } }
The output is shown in Logcat:
                                         

Baca Selengkapnya ....

ListView in Alphabetic Order in ANDROID

Posted by Unknown Jumat, 01 Maret 2013 0 komentar
Java class: 
public class MainActivity extends ListActivity {
static final String[] items = new String[] { "Babbage","Boole", "Berners-Lee",
"Atanasoff", "Allen","Cormack", "Cray","Dijkstra","Dix","Dewey",
"Erdos","Zebra" };

ArrayAdapter<string> arrayadapter;
ListView listview;
ArrayList<string> arraylist;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arraylist= new ArrayList<String>();
for(int i=0;i<items.length;i++)
{
arraylist.add(FRUITS[i]);
}
Collections.sort(arraylist );//for sorting arraylist
arrayadapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arraylist);
listview=getListView();
listview.setAdapter(arrayadapter);
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent,View view,
int position, long id)
{
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}});}}
                 

Baca Selengkapnya ....

Activity Life Cycle of Android

Posted by Unknown 0 komentar
An activity is usually a single screen that the user sees on the device at one time. An application typically has multiple activities, and the user flips back and forth among them. As such, activities are the most visible part of your application.Activity Manager is responsible for creating, destroying, and managing activities. For example, when the user starts an application for the first time, the Activity Manager will create its activity and put it onto the screen. Later, when the user switches screens, the Activity Manager will move that previous activity to a holding place. This way, if the user wants to go back to an older activity, it can be started more quickly. Older activities that the user hasn’t used in a while will be destroyed in order to free more space for the currently active one. This mechanism is designed to help improve the speed of the user interface and thus improve the overall user experience.

An Activity in Android can exist in four states as described below:
1.  Active/Running state
This is a state when an activity is in the front and has focus in it. It is completely visible and active to the user.
2. Paused state
In paused state, the activity is partially visible to the user but not active and lost focus. This occurs when some another Activity is on top of this one which doesnot cover the entire screen or having some transparancy so that the underlying Activity is partially visible. A paused activity is completely alive and maintains its state but it can be killed by system under low memory when memory can be freed by no other ways.
3.  Stopped state
This is when the Activity is no longer visible in the screen. Another activity is on top of it and completely obscures its view. In this state also the activity is alive and preserves its state, but more likely to be killed by the system to free resources whenever necessary
4. Destroyed/Dead state
An Activity is said to be dead or destroyed when it no longer exists in the memory. Either the Activity hasn’t been started yet or once it was started and killed by the system in Paused or Stopped state to free resources.

  • When we launch an Activity in Android, it first calls the onCreate() method. This is where we do User Interface creation and initialization of data elements. This method is provided with a Bundle object as parameter to restore the UI state.
  • onStart() method is called before the Activity is being visible to the User. Remember that Activity is still not Active.
  • With the onResume() method, the Activity become visible and Active for the user to interact with. The Activity will be at the top of the Activity stack at this point. Now the Activity is in running /active state and is able to receive user inputs.
  • In the Active state, onPause() method will be called when the system is about to resume another Activity on top of this one or when the user is about to navigate to some other other parts of the system. It is the last guaranteed call to a method before the Activity  can get killed by the system. That is, there’s a possibility that your activity may be killed by the system at the paused state without executing any further method calls. Therefore it is important to save the user interface configuration and critical data at this method.
  • By default, an Activity can remain in the paused state if:
  • The user has pressed the home button
  • Another activity or notification which is on top of it doesn’t completely obscures the visibility of underlying Activity.
  • The device goes to sleep.
  • There are three possibilities for an Activity under paused state:
  1. The user resumes the Activity by closing the new Activity or notification and the paused Activity gets Active/Running by calling onResume() method.
  2. It gets killed by the system under extremely low memory conditions. In this case there will be no further method calls before the destruction of the Activity and it needs to be re-run from the beginning by calling onCreate() and restoring the previous configuration from bundle object.
In all other cases it goes to stopped state by executing onStop() method. This is the default action when the user has pressed the back button, or a new activity which completely covers it resumes on top.
  • An Activity under stopped state also has three different scenarios to happen:
  1. System kills it to free resources. An activity under stopped sate is more likely to be killed by the system than one in the paused state. It needs to start the cycle again with onCreate().
  2. It get restarted by calling onRestart() , onStart() and onResume() methods in the order if the user navigates back to the Activity again. In this case, the User Interface is intact and no need to be restored.
  3. onDestroy() method is called and the Activity is destroyed. This is the final method we can call before the Activity is destroyed. This occurs either because the Activity is finishing the operation or the system is temporarily destroying it to save space.

Android Activity Lifecycle Loops

By analyzing the Android Activity lifecycle diagram we can see there are three lifecycle loops exist for every Activity and are defined by those callback methods.
They are:
Entire Lifetime: This is the lifetime between the first call to the onCreate() and the final call to onDestroy() method. We create all global resources such as screen layout, global variables etc in onCreate() and release all resources with onDestroy() call.
Visible Lifetime:  It is the lifetime of an Activity between onStart() and onStop() method calls. In this the Activity is visible to the user and he may or may not be able to interact with it. During the visible lifetime, an Activity maintains its state intact.
Foreground Lifetime:  Foreground lifetime starts with onResume() and ends with onPause() method calls. During this, the Activity is completely visible to the user and is on top of all other Activities so that user can interact with it.
 


Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.