tag:blogger.com,1999:blog-57786621978681126392024-03-23T16:37:20.193+05:30Android Solution and SamplesAndroid development with simple sample programs and tutorials from android First program. Learn android easily.Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.comBlogger55125tag:blogger.com,1999:blog-5778662197868112639.post-89667515526523582422016-04-25T16:53:00.000+05:302016-04-25T17:07:23.841+05:30Get GPS current location coordinates and city name<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" style="text-align: left;">
Get Current Location coordinates/GPS coordinates and get City name<br /><span style="font-size: small;"><br /><br /><span style="font-weight: normal;">I have already tested this app on my android phone and one more thing when you move line 10-20 meter you will get the new coordinates.</span></span></h3>
<h3 class="post-title entry-title" style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;">What is app does?</span></span></h3>
<div>
<ul style="text-align: left;">
<li>check gps is enable or disable</li>
<li>Get gps coordinates</li>
<li>Get the current city name.</li>
</ul>
</div>
<h3 class="post-title entry-title" style="text-align: left;">
<span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;"> </span><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">-------------------------------------------</span><br /><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">App Name: </span><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif;"><span style="font-size: 15px; line-height: 20px;"><b>GetMyCurrentLocation</b></span></span><br /><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">Package Name: </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">com.example.hemant.may_i_help_u</span></h3>
<h3 class="post-title entry-title" style="text-align: left;">
<span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">Android SDK: </span><b style="color: #363636; font-family: 'times new roman', times, freeserif, serif; font-size: 15px; line-height: 20px;">Android SDK 2.3.3 / API 10</b><br /><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">Default Activity Name: </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">MainActivity</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;"> </span></h3>
<h3 class="post-title entry-title" style="text-align: left;">
<span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif; font-size: 15px; line-height: 20px;">-------------------------------------------</span><br /><span style="color: #363636; font-family: "times new roman" , "times" , "freeserif" , serif;"><span style="font-size: 15px; font-weight: normal; line-height: 20px;"><br /></span></span></h3>
<h3 class="post-title entry-title" style="text-align: left;">
<span style="color: navy; font-family: "courier new"; font-size: 9pt;">package </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">com.example.hemant.may_i_help_u;</span><br /><span style="font-family: "courier new";"><br /><span style="font-size: 12px; font-weight: normal;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.app.Activity;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.app.AlertDialog;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.ContentResolver;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.Context;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.DialogInterface;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.Intent;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.pm.ActivityInfo;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.content.pm.PackageManager;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.location.Address;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.location.Geocoder;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.location.Location;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.location.LocationListener;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.location.LocationManager;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.os.Build;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.os.Bundle;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.provider.Settings;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.support.v4.app.ActivityCompat;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.support.v4.content.ContextCompat;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.util.Log;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.view.View;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.view.View.OnClickListener;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.widget.Button;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.widget.EditText;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.widget.ProgressBar;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">android.widget.Toast;</span><br /><span style="font-family: "courier new";"><span style="font-size: 12px; font-weight: normal;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">java.io.IOException;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">java.util.List;</span><br /><span style="color: navy; font-family: "courier new"; font-size: 9pt;">import </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">java.util.Locale;</span><br /><span style="font-family: "courier new";"><span style="font-size: 12px; font-weight: normal;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">public class </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">MainActivity </span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">extends </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Activity </span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">implements </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">OnClickListener {</span><br /><span style="font-family: "courier new";"><span style="font-size: 12px; font-weight: normal;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">LocationManager </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt;">locationMangaer</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">=</span><span style="color: navy; font-family: "courier new"; font-size: 9pt;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span></h3>
<div class="post-header" style="text-align: left;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-5813602696592305610">
<div dir="ltr" trbidi="on">
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">LocationListener </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">locationListener</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">=</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Button </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">btnGetLocation </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">EditText </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">editLocation </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">ProgressBar </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">pb </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">=</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private static final </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">String </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TAG </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Debug"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Boolean </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">flag </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">false</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onCreate(Bundle savedInstanceState) {</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">super</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.onCreate(savedInstanceState);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">setContentView(R.layout.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">activity_main</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><br /><span style="font-size: 12px;"><br /></span></span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">//if you want to lock screen for always Portrait mode</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">setRequestedOrientation(ActivityInfo</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">SCREEN_ORIENTATION_PORTRAIT</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">pb </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= (ProgressBar) findViewById(R.id.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">progressBar1</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">pb</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setVisibility(View.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">INVISIBLE</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">editLocation </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= (EditText) findViewById(R.id.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">editTextLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">btnGetLocation </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= (Button) findViewById(R.id.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">btnLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">btnGetLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setOnClickListener(</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">this</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">locationMangaer </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= (LocationManager)</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">getSystemService(Context.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">LOCATION_SERVICE</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onClick(View v) {</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">flag </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= displayGpsStatus();</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">if </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">flag</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">) {</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Log.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">v</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TAG</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"onClick"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">editLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setText(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Please!! move your device to"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+</span><br />
<span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">" see the changes in coordinates."</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">\n</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">Wait.."</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">pb</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setVisibility(View.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">VISIBLE</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">locationListener </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">= </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">MyLocationListener();</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">if </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">( Build.VERSION.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">SDK_INT </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">>= </span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">23 </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">&&</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">ContextCompat.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">checkSelfPermission</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">( MainActivity.</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">this</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, android.Manifest.permission.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">ACCESS_FINE_LOCATION </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">) != PackageManager.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">PERMISSION_GRANTED </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">&&</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">ContextCompat.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">checkSelfPermission</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">( MainActivity.</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">this</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, android.Manifest.permission.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">ACCESS_COARSE_LOCATION</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">) != PackageManager.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">PERMISSION_GRANTED</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">) {</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">return </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">locationMangaer</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.requestLocationUpdates(LocationManager.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">GPS_PROVIDER</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, </span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">5000</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, </span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">10</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, </span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">locationListener</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><br /><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">} </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">else </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">{</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">alertbox(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Gps Status!!"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Your GPS is: OFF"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">/*----Method to Check GPS is enable or disable ----- */</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Boolean displayGpsStatus() {</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">LocationManager lm = (LocationManager)MainActivity.</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">this</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.getSystemService(Context.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">LOCATION_SERVICE</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">boolean </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">gps_enabled = </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">false</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">try </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">{</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">gps_enabled = lm.isProviderEnabled(LocationManager.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">GPS_PROVIDER</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">} </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">catch</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(Exception ex) {}</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">return </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">gps_enabled;</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">/*----------Method to create an AlertBox ------------- */</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">protected void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">alertbox(String title, String mymessage) {</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">AlertDialog.Builder builder = </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">AlertDialog.Builder(</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">this</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">builder.setMessage(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Your Device's GPS is Disable"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">)</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setCancelable(</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">false</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">)</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setTitle(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"** Gps Status **"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">)</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setPositiveButton(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Gps On"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">,</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">DialogInterface.OnClickListener() {</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onClick(DialogInterface dialog, </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">int </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">id) {</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// finish the current activity</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// AlertBoxAdvance.this.finish();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Intent myIntent = </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Intent(</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Settings.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">ACTION_SECURITY_SETTINGS</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">startActivity(myIntent);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">dialog.cancel();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">})</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setNegativeButton(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Cancel"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">,</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">DialogInterface.OnClickListener() {</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onClick(DialogInterface dialog, </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">int </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">id) {</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// cancel the dialog box</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">dialog.cancel();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">});</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">AlertDialog alert = builder.create();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">alert.show();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">/*----------Listener class to get coordinates ------------- */</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">private class </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">MyLocationListener </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">implements </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">LocationListener {</span><br />
<span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onLocationChanged(Location loc) {</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">editLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setText(</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">""</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">pb</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setVisibility(View.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">INVISIBLE</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Toast.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">makeText</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(getBaseContext(),</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Location changed : Lat: " </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">loc.getLatitude()+ </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">" Lng: " </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+ loc.getLongitude(),</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Toast.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">LENGTH_SHORT</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">).show();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">String longitude = </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Longitude: " </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+loc.getLongitude();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Log.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">v</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TAG</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, longitude);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">String latitude = </span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"Latitude: " </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+loc.getLatitude();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Log.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">v</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TAG</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">, latitude);</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">/*----------to get City-Name from coordinates ------------- */</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">String cityName=</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">null</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">;</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Geocoder gcd = </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">new </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Geocoder(getBaseContext(),</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">Locale.</span><span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">getDefault</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">());</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">List<Address> addresses;</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">try </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">{</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">addresses = gcd.getFromLocation(loc.getLatitude(), loc</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.getLongitude(), </span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">1</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">);</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">if </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(addresses.size() > </span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">0</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">)</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">System.</span><span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">out</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.println(addresses.get(</span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">0</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">).getLocality());</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">cityName=addresses.get(</span><span style="color: blue; font-family: "courier new"; font-size: 9pt;">0</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">).getLocality();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">} </span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">catch </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">(IOException e) {</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">e.printStackTrace();</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">String s = longitude+</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">\n</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+latitude +</span><br />
<span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">"</span><span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">\n\n</span><span style="color: green; font-family: "courier new"; font-size: 9pt; font-weight: bold;">My Currrent City is: "</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">+cityName;</span><br />
<span style="color: #660e7a; font-family: "courier new"; font-size: 9pt; font-weight: bold;">editLocation</span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">.setText(s);</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onProviderDisabled(String provider) {</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// </span><span style="color: #0073bf; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onProviderEnabled(String provider) {</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// </span><span style="color: #0073bf; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="font-family: "courier new";"><span style="font-size: 12px;"><br /></span></span><span style="color: olive; font-family: "courier new"; font-size: 9pt;">@Override</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">public void </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">onStatusChanged(String provider,</span><br />
<span style="color: navy; font-family: "courier new"; font-size: 9pt; font-weight: bold;">int </span><span style="background-color: white; font-family: "courier new"; font-size: 9pt;">status, Bundle extras) {</span><br />
<span style="font-family: "courier new"; font-size: 9pt; font-style: italic;">// </span><span style="color: #0073bf; font-family: "courier new"; font-size: 9pt; font-style: italic; font-weight: bold;">TODO Auto-generated method stub</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<span style="background-color: white; font-family: "courier new"; font-size: 9pt;">}</span><br />
<b><u>main.xml</u></b><br />
<span class="tag"><?</span><span class="tag-name">xml</span> <span class="attribute">version</span>=<span class="attribute-value">"1.0"</span> <span class="attribute">encoding</span>=<span class="attribute-value">"utf-8"</span><span class="tag">?></span><br />
<span class="tag"><</span><span class="tag-name">LinearLayout</span><br />
<span class="attribute">xmlns:android</span>=<span class="attribute-value">"http://schemas.android.com/apk/res/android"</span><br />
<span class="attribute">android:orientation</span>=<span class="attribute-value">"vertical"</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"fill_parent"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"fill_parent"</span><br />
<span class="attribute">android:weightSum</span>=<span class="attribute-value">"1"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">TextView</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"fill_parent"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:text</span>=<span class="attribute-value">"Get Current Location and City Name"</span><br />
<span class="attribute">android:layout_weight</span>=<span class="attribute-value">"0.20"</span><br />
<span class="attribute">android:gravity</span>=<span class="attribute-value">"center"</span><br />
<span class="attribute">android:textSize</span>=<span class="attribute-value">"20sp"</span> <span class="tag">/></span><br />
<span class="tag"><</span><span class="tag-name">EditText</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"match_parent"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:layout_weight</span>=<span class="attribute-value">"0.33"</span><br />
<span class="attribute">android:id</span>=<span class="attribute-value">"@+id/editTextLocation"</span><br />
<span class="attribute">android:editable</span>=<span class="attribute-value">"false"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">requestFocus</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">requestFocus</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">EditText</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">LinearLayout</span><br />
<span class="attribute">android:id</span>=<span class="attribute-value">"@+id/layButtonH"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"fill_parent"</span><br />
<span class="attribute">android:gravity</span>=<span class="attribute-value">"center"</span><br />
<span class="attribute">android:layout_weight</span>=<span class="attribute-value">"0.15"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">Button</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:text</span>=<span class="attribute-value">"Get Location"</span><br />
<span class="attribute">android:id</span>=<span class="attribute-value">"@+id/btnLocation"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">Button</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">LinearLayout</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">LinearLayout</span><br />
<span class="attribute">android:id</span>=<span class="attribute-value">"@+id/layloadingH"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:layout_weight</span>=<span class="attribute-value">"0.20"</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"fill_parent"</span><br />
<span class="attribute">android:gravity</span>=<span class="attribute-value">"center"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">ProgressBar</span><br />
<span class="attribute">android:layout_width</span>=<span class="attribute-value">"wrap_content"</span><br />
<span class="attribute">android:id</span>=<span class="attribute-value">"@+id/progressBar1"</span><br />
<span class="attribute">android:layout_height</span>=<span class="attribute-value">"wrap_content"</span><span class="tag">></span><span class="tag"></</span><span class="tag-name">ProgressBar</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">LinearLayout</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">LinearLayout</span><span class="tag">></span><br />
<br />
<b><u>AndroidManifest.xml</u></b><br />
<span class="tag"><?</span><span class="tag-name">xml</span> <span class="attribute">version</span>=<span class="attribute-value">"1.0"</span> <span class="attribute">encoding</span>=<span class="attribute-value">"utf-8"</span><span class="tag">?></span><br />
<span class="tag"><</span><span class="tag-name">manifest</span><br />
<span class="attribute">xmlns:android</span>=<span class="attribute-value">"http://schemas.android.com/apk/res/android"</span><br />
<span class="attribute">package</span>=<span class="attribute-value">"com.rdc"</span><br />
<span class="attribute">android:versionCode</span>=<span class="attribute-value">"1"</span><br />
<span class="attribute">android:versionName</span>=<span class="attribute-value">"1.0"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">uses-sdk</span> <span class="attribute">android:minSdkVersion</span>=<span class="attribute-value">"10"</span> <span class="tag">/></span><br />
<br />
<span class="tag"><</span><span class="tag-name">uses-permission</span> <span class="attribute">android:name</span>=<span class="attribute-value">"android.permission.ACCESS_FINE_LOCATION"</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">uses-permission</span><span class="tag">></span><br />
<br />
<span class="tag"><</span><span class="tag-name">application</span><br />
<span class="attribute">android:icon</span>=<span class="attribute-value">"@drawable/icon"</span><br />
<span class="attribute">android:label</span>=<span class="attribute-value">"@string/app_name"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">activity</span><br />
<span class="attribute">android:name</span>=<span class="attribute-value">".GetCurrentLocation"</span><br />
<span class="attribute">android:label</span>=<span class="attribute-value">"@string/app_name"</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">intent-filter</span><span class="tag">></span><br />
<span class="tag"><</span><span class="tag-name">action</span> <span class="attribute">android:name</span>=<span class="attribute-value">"android.intent.action.MAIN"</span> <span class="tag">/></span><br />
<span class="tag"><</span><span class="tag-name">category</span> <span class="attribute">android:name</span>=<span class="attribute-value">"android.intent.category.LAUNCHER"</span> <span class="tag">/></span><br />
<span class="tag"></</span><span class="tag-name">intent-filter</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">activity</span><span class="tag">></span><br />
<br />
<span class="tag"></</span><span class="tag-name">application</span><span class="tag">></span><br />
<span class="tag"></</span><span class="tag-name">manifest</span><span class="tag">></span><br />
<br />
The output Screen will be like this..<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5l45G8YxW1VR7DLS2rCRBzVNBWnwNQaPqxDjOfeJJ8YaA70tcnk953QBI-enTs23DyC13kBFlKhM9m42gXy1_p5HlCu8ET6F8zkfPfxNFgtT6ORwBCnrbXm90zA3yeoOOHTKJ_KISA3g/s1600/getcoordinatesandcityname.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5l45G8YxW1VR7DLS2rCRBzVNBWnwNQaPqxDjOfeJJ8YaA70tcnk953QBI-enTs23DyC13kBFlKhM9m42gXy1_p5HlCu8ET6F8zkfPfxNFgtT6ORwBCnrbXm90zA3yeoOOHTKJ_KISA3g/s320/getcoordinatesandcityname.jpg" width="216" /></a>
<br />
<div class="dp-highlighter">
</div>
<div class="dp-highlighter">
</div>
<div class="dp-highlighter">
</div>
</div>
</div>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com3tag:blogger.com,1999:blog-5778662197868112639.post-32956944717238471182016-04-25T16:08:00.001+05:302016-04-25T16:43:25.527+05:30Check if GPS/Network Provider Services are enabled or not?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2 style="text-align: left;">
<u>How to check if GPS/Network Provider Services are enabled?</u></h2>
<div>
<br /></div>
<div>
<pre class="default prettyprint prettyprinted"><code><span class="typ">LocationManager</span><span class="pln"> lm </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">LocationManager</span><span class="pun">)</span><span class="pln">context</span><span class="pun">.</span><span class="pln">getSystemService</span><span class="pun">(</span><span class="typ">Context</span><span class="pun">.</span><span class="pln">LOCATION_SERVICE</span><span class="pun">);</span><span class="pln">
</span><span class="kwd">boolean</span><span class="pln"> gps_enabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">boolean</span><span class="pln"> network_enabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">try</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
gps_enabled </span><span class="pun">=</span><span class="pln"> lm</span><span class="pun">.</span><span class="pln">isProviderEnabled</span><span class="pun">(</span><span class="typ">LocationManager</span><span class="pun">.</span><span class="pln">GPS_PROVIDER</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln"> </span><span class="kwd">catch</span><span class="pun">(</span><span class="typ">Exception</span><span class="pln"> ex</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{}</span><span class="pln">
</span><span class="kwd">try</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
network_enabled </span><span class="pun">=</span><span class="pln"> lm</span><span class="pun">.</span><span class="pln">isProviderEnabled</span><span class="pun">(</span><span class="typ">LocationManager</span><span class="pun">.</span><span class="pln">NETWORK_PROVIDER</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln"> </span><span class="kwd">catch</span><span class="pun">(</span><span class="typ">Exception</span><span class="pln"> ex</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{}</span><span class="pln">
</span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">gps_enabled </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">!</span><span class="pln">network_enabled</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// notify user</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="typ">AlertDialog</span><span class="pun">.</span><span class="typ">Builder</span><span class="pln"> dialog </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">AlertDialog</span><span class="pun">.</span><span class="typ">Builder</span><span class="pun">(</span><span class="pln">context</span><span class="pun">);</span><span class="pln">
dialog</span><span class="pun">.</span><span class="pln">setMessage</span><span class="pun">(</span><span class="pln">context</span><span class="pun">.</span><span class="pln">getResources</span><span class="pun">().</span><span class="pln">getString</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="kwd">string</span><span class="pun">.</span><span class="pln">gps_network_not_enabled</span><span class="pun">));</span><span class="pln">
dialog</span><span class="pun">.</span><span class="pln">setPositiveButton</span><span class="pun">(</span><span class="pln">context</span><span class="pun">.</span><span class="pln">getResources</span><span class="pun">().</span><span class="pln">getString</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="kwd">string</span><span class="pun">.</span><span class="pln">open_location_settings</span><span class="pun">),</span><span class="pln"> </span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="kwd">new</span><span class="pln"> </span><span class="typ">DialogInterface</span><span class="pun">.</span><span class="typ">OnClickListener</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="lit">@Override</span><span class="pln">
</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onClick</span><span class="pun">(</span><span class="typ">DialogInterface</span><span class="pln"> paramDialogInterface</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> paramInt</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
</span><span class="typ">Intent</span><span class="pln"> myIntent </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Intent</span><span class="pun">(</span><span class="pln"> </span><span class="typ">Settings</span><span class="pun">.</span><span class="pln">ACTION_LOCATION_SOURCE_SETTINGS</span><span class="pun">);</span><span class="pln">
context</span><span class="pun">.</span><span class="pln">startActivity</span><span class="pun">(</span><span class="pln">myIntent</span><span class="pun">);</span><span class="pln">
</span><span class="com">//get gps</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span><span class="pln">
dialog</span><span class="pun">.</span><span class="pln">setNegativeButton</span><span class="pun">(</span><span class="pln">context</span><span class="pun">.</span><span class="pln">getString</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="kwd">string</span><span class="pun">.</span><span class="typ">Cancel</span><span class="pun">),</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">DialogInterface</span><span class="pun">.</span></code></pre>
<pre class="default prettyprint prettyprinted"><span class="typ">OnClickListener</span><span class="pun">()</span></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="lit">@Override</span><span class="pln">
</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onClick</span><span class="pun">(</span><span class="typ">DialogInterface</span><span class="pln"> paramDialogInterface</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> paramInt</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">});</span><span class="pln">
dialog</span><span class="pun">.</span><span class="pln">show</span><span class="pun">();</span><span class="pln">
</span><span class="pun">}</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun">
</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun">
</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"><u>Add below permissions in androidManifest.xml </u></span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"><u>
</u></span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"><pre class="default prettyprint prettyprinted"><code><span class="tag"><uses-permission</span><span class="pln"> </span><span class="atn">android:name</span><span class="pun">=</span><span class="atv">"android.permission.ACCESS_FINE_LOCATION"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><uses-permission</span><span class="pln"> </span><span class="atn">android:name</span><span class="pun">=</span><span class="atv">"android.permission.ACCESS_COARSE_LOCATION"</span><span class="tag">/></span></code></pre>
</span></code></pre>
<pre class="default prettyprint prettyprinted">
</pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun">//-----------------------------------------------------------------------</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"><u><b>NOTE:-if you got any warning message like</b> </u>"Call requires permission which may be rejected</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"> by user. Code should explicitly check to see if permission is available." then you can </span></code></pre>
<pre class="default prettyprint prettyprinted">try one by one of below step.</pre>
<pre class="default prettyprint prettyprinted">
</pre>
<pre class="default prettyprint prettyprinted">
</pre>
<pre class="default prettyprint prettyprinted">1) Ensure you have your permissions listed in the Manifest:<br />
<pre class="default prettyprint prettyprinted"><code><span class="tag"><uses-permission</span><span class="pln"> </span><span class="atn">android:name</span><span class="pun">=</span><span class="atv">"android.permission.ACCESS_FINE_LOCATION"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><uses-permission</span><span class="pln"> </span><span class="atn">android:name</span><span class="pun">=</span><span class="atv">"android.permission.ACCESS_COARSE_LOCATION"</span><span class="tag">/></span></code></pre>
(2) Ensure you use ContextCompat as this has compatibility with older API levels. <br />
(3) In your location service, or class that initializes your
LocationManager and gets the last known location, we need to check the
permissions: <br />
<pre class="default prettyprint prettyprinted"><code><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="typ">Build</span><span class="pun">.</span><span class="pln">VERSION</span><span class="pun">.</span><span class="pln">SDK_INT </span><span class="pun">>=</span><span class="pln"> </span><span class="lit">23</span><span class="pln"> </span><span class="pun">&&</span><span class="pln">
</span><span class="typ">ContextCompat</span><span class="pun">.</span><span class="pln">checkSelfPermission</span><span class="pun">(</span><span class="pln"> context</span><span class="pun">,</span><span class="pln"> android</span><span class="pun">.</span><span class="typ">Manifest</span><span class="pun">.</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">ACCESS_FINE_LOCATION </span><span class="pun">)</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">PackageManager</span><span class="pun">.</span><span class="pln">PERMISSION_GRANTED </span><span class="pun">&&</span><span class="pln">
</span><span class="typ">ContextCompat</span><span class="pun">.</span><span class="pln">checkSelfPermission</span><span class="pun">(</span><span class="pln"> context</span><span class="pun">,</span><span class="pln"> android</span><span class="pun">.</span><span class="typ">Manifest</span><span class="pun">.</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">ACCESS_COARSE_LOCATION</span><span class="pun">)</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">PackageManager</span><span class="pun">.</span><span class="pln">PERMISSION_GRANTED</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="kwd">return</span><span class="pln"> </span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun">
</span></code></pre>
</pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun"><pre class="default prettyprint prettyprinted">(4) Ensure you request permissions from the user: <br />
<pre class="default prettyprint prettyprinted"><code><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="typ">ContextCompat</span><span class="pun">.</span><span class="pln">checkSelfPermission</span><span class="pun">(</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">,</span><span class="pln"> android</span><span class="pun">.</span><span class="typ">Manifest</span><span class="pun">.</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">ACCESS_COARSE_</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln">LOCATION </span><span class="pun">)</span><span class="pln"> </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">PackageManager</span><span class="pun">.</span><span class="pln">PERMISSION_GRANTED </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="typ">ActivityCompat</span><span class="pun">.</span><span class="pln">requestPermissions</span><span class="pun">(</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">String</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> android</span><span class="pun">.</span><span class="typ">Manifest</span><span class="pun">.</span><span class="pln">permission</span><span class="pun">.</span><span class="pln">ACCESS_COARSE_LOCATION </span><span class="pun">},</span><span class="pln">
</span><span class="typ">LocationService</span><span class="pun">.</span><span class="pln">MY_PERMISSION_ACCESS_COURSE_LOCATION </span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span></code></pre>
<div>
<code><span class="pun">
</span></code></div>
</pre>
</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pun">
</span></code></pre>
</div>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com3tag:blogger.com,1999:blog-5778662197868112639.post-8390410967135650412012-11-16T17:07:00.001+05:302012-11-16T17:07:15.413+05:30Android Interviews<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 class="post-title entry-title" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font: normal normal normal 24px/normal Georgia, Utopia, 'Palatino Linotype', Palatino, serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0.75em; position: relative; text-align: -webkit-auto;">
Android interview questions</h3>
<div class="post-header" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 13px; line-height: 1.6; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: -webkit-auto;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 1.4; position: relative; text-align: -webkit-auto; width: 520px;">
<div class="MsoNormal">
<b>What is an action?</b><br />
The Intent Sender desires something or doing some task<br />
<br />
<b>What is activity?</b><br />
A single screen in an application, with supporting Java code.<br />
<br />
<b>What is intent in Android?</b><br />
A class (Intent) will describes what a caller desires to do. The caller will send this intent to Android's intent resolver, which finds the most suitable <span class="IL_AD" id="IL_AD2" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">activity for</span> the intent. E.g. opening a <span class="IL_AD" id="IL_AD4" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">PDF document</span> is an intent, and the <span class="IL_AD" id="IL_AD3" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Adobe Reader</span> apps will be the perfect activity for that intent(class).<br />
<br />
<b>What is a Sticky Intent?</b><br />
sendStickyBroadcast() performs a sendBroadcast (Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver (BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent).</div>
<div class="MsoNormal">
One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.</div>
<div class="MsoNormal">
Is there anyway to <span class="IL_AD" id="IL_AD9" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">determine</span> if an Intent passed into a BroadcastReceiver's onReceive is the result of a sticky Boradcast Intent, or if it was just sent?<br />
<br />
<b>Example for sticky broadcast</b><br />
When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.<br />
<br />
<b>How the nine-patch Image different from a regular bitmap? or Different between nine-patch Image vs regular Bitmap Image</b><br />
It is one of a resizable bitmap resource which is being used as <span class="IL_AD" id="IL_AD8" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">backgrounds</span> or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.<br />
<br />
<b>What Programming languages does Android support <span class="IL_AD" id="IL_AD7" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">for application</span>development?</b><br />
Android applications supports using Java Programming Language. which is coded in Java and complied using <span class="IL_AD" id="IL_AD10" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Android SDK</span>.<br />
<br />
<b>What is a resource?</b><br />
A user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.<br />
<br />
<b>How will you record <span class="IL_AD" id="IL_AD5" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">a phone call</span> in Android? or How to handle on Audio Stream for a call in Android?</b><br />
Permissions.PROCESS_OUTGOING_CALLS: Will Allows an application to monitor, modify, or abort outgoing calls. So through that we can monitor the Phone calls.<br />
<br />
<b>What's the difference between class, file and activity in android?</b><br />
Class - The <span class="IL_AD" id="IL_AD6" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Class file</span> is complied from .java file. Android will use this .class fileto produce the executable apk.<br />
File - It is a block of resources, srbitrary information. It can be any file type.<br />
Activity - An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.<br />
<br />
<b>Does Android support the Bluetooth serial port profile?</b><br />
A. Yes.<br />
<b>Can an application be started on powerup?</b><br />
A. Yes.<br />
<br />
<b>What is APK format.</b><br />
The APK file is compressed AndroidManifest.xml file with extension .apk, Which have application code (.dex files), resource files, and other files which is compressed into single .apk file.<br />
<br />
<b>How to Translate in android</b><br />
The <span class="IL_AD" id="IL_AD12" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Google translator</span> translates the data of one language into <span class="IL_AD" id="IL_AD11" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">another language</span> by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens.<br />
<br />
<b>What is an action?</b><br />
A description of something that an Intent sender desires.<br />
<br />
<b>What are the advantages of Android?</b><br />
The following are the advantages of Android:<br />
<br />
* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like Orange and AT&T will be broken by Google Android.<br />
* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized<br />
* Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.</div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b>What is the TTL (Time to Live)? Why is it required?</b></div>
<div class="MsoNormal">
TTL is a value in data packet of Internet Protocol. It communicates to the network router whether or not the packet should be in the network for too long or discarded. Usually, data packets might not be transmitted to their intended destination within a stipulated period of time. The TTL value is set by a system default value which is an 8-bit binary digit field in the header of the packet. The purpose of TTL is, it would specify certain time limit in seconds, for transmitting the packet header. When the time is exhausted, the packet would be discarded. Each router receives the subtracts count, when the packet is discarded, and when it becomes zero, the router detects the discarded packets and sends a message, Internet Control Message Protocol message back to the originating host.</div>
<div class="MsoNormal">
<b>How is nine-patch image different from a regular bitmap?</b></div>
<div class="MsoNormal">
It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.</div>
<div class="MsoNormal">
<b>Explain IP datagram, Fragmentation and MTU ?</b></div>
<div class="MsoNormal">
IP datagram can be used to describe a portion of IP data. Each IP datagram has set of fields arranged in an order. The order is specific which helps to decode and read the stream easily. IP datagram has fields like Version, header length, Type of service, Total length, checksum, flag, protocol, Time to live, Identification, source and destination ip address, padding, options and payload.</div>
<div class="MsoNormal">
MTU:- Maximum Transmission Unit is the size of the largest packet that a communication protocol can pass. The size can be fixed by some standard or decided at the time of connection</div>
<div class="MsoNormal">
Fragmentation is a process of breaking the IP packets into smaller pieces. Fragmentation is needed when the datagram is larger than the MTU. Each fragment becomes a datagram in itself and transmitted independently from source. When received by destination they are reassembled.</div>
<div class="MsoNormal">
<b>Explain about the exceptions of Android?</b></div>
<div class="MsoNormal">
The following are the exceptions that are supported by Android<br />
* InflateException : When an error conditions are occurred, this exception is thrown<br />
* Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown<br />
* SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS<br />
* WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.</div>
<div class="MsoNormal">
<b>Describe Android Application Architecture?</b></div>
<div class="MsoNormal">
Android Application Architecture has the following components:</div>
<div class="MsoNormal">
* Services ? like Network Operation</div>
<div class="MsoNormal">
* Intent - To perform inter-communication between activities or services</div>
<div class="MsoNormal">
* Resource Externalization - such as strings and graphics</div>
<div class="MsoNormal">
* <span class="IL_AD" id="IL_AD1" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Notification</span> signaling users - light, sound, icon, notification, dialog etc.</div>
<div class="MsoNormal">
* Content Providers - They share data between applications</div>
<div class="MsoNormal">
<b>What are the advantages of Android?</b></div>
<div class="MsoNormal">
The following are the advantages of Android:</div>
<div class="MsoNormal">
* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.</div>
<div class="MsoNormal">
* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized</div>
<div class="MsoNormal">
* Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.</div>
<div class="MsoNormal">
<b>How to select more than one option from list in android xml file? Give an example.</b></div>
<div class="MsoNormal">
Specify android id, layout height and width as depicted in the following example.<br />
<br />
<listview id="@+id/ListView01" layout_height="wrap_content" layout_width="fill_parent"></listview></div>
<div class="MsoNormal">
<b>Explain about the exceptions of Android?</b></div>
<div class="MsoNormal">
The following are the exceptions that are supported by Android</div>
<div class="MsoNormal">
* InflateException : When an error conditions are occurred, this exception is thrown</div>
<div class="MsoNormal">
* Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown</div>
<div class="MsoNormal">
* SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS</div>
<div class="MsoNormal">
* WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.</div>
<div class="MsoNormal">
<b>What are the features of Android?</b></div>
<div class="MsoNormal">
*Components can be reused and replaced by the application framework.</div>
<div class="MsoNormal">
*Optimized DVM for mobile devices</div>
<div class="MsoNormal">
*SQLite enables to store the data in a structured manner.</div>
<div class="MsoNormal">
*Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies</div>
<div class="MsoNormal">
*The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.</div>
<div class="MsoNormal">
<b>What are the differences between a domain <span id="IL_AD7"><span class="ilad">and a</span></span> workgroup?</b></div>
<div class="MsoNormal">
In a domain, one or more computer can be a server to manage the network. On the other hand in a workgroup all computers are peers having no control on each other. In a domain, user doesn?t need an account to logon on a specific computer if an account is available on the domain. In a work group user needs to have an account for every computer.</div>
<div class="MsoNormal">
In a domain, Computers can be on different local networks. In a work group all computers needs to be a part of the same local network.</div>
<div class="MsoNormal">
<b>What is android?</b></div>
<div class="MsoNormal">
Android is a stack of <span class="ilad"><span id="IL_AD3">software for mobile</span></span> devices which has Operating System,<span class="ilad"><span id="IL_AD1">middleware</span></span> and some key applications. The <span class="ilad"><span id="IL_AD4">application</span></span> executes within its own process and its own instance of Dalvik <span class="ilad"><span id="IL_AD7" style="font-weight: bold !important;">Virtual Machine</span></span>. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later <span class="ilad"><span id="IL_AD5" style="font-weight: bold !important;">transforms</span></span> into .dex format files.</div>
<div class="MsoNormal">
<b>What is needed to make a <span id="IL_AD2" style="font-weight: normal !important;"><span class="ilad">multiple choice</span></span> list with a custom view for each row?</b></div>
<div class="MsoNormal">
Multiple choice list can be viewed by making the <span class="ilad"><span id="IL_AD4">CheckBox</span></span> android:id value be “@android:id /text1". That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.</div>
<div class="MsoNormal">
<b>What are the dialog boxes that are supported in android? Explain.</b></div>
<div class="MsoNormal">
Android supports 4 dialog boxes:<br />
<br />
AlertDialog : An alert <span class="ilad"><span id="IL_AD7" style="font-weight: bold !important;">dialog box</span></span> supports 0 to 3 buttons and a list of selectable elements, including check boxes and <span class="ilad"><span id="IL_AD6">radio buttons</span></span>. Among the other dialog boxes, the most suggested dialog box is the alert dialog box.<br />
<br />
ProgressDialog: This dialog box displays a progress wheel or a progress <span class="ilad"><span id="IL_AD8">bar</span></span>. It is an extension of AlertDialog and supports adding buttons.<br />
<br />
DatePickerDialog: This dialog box is used for selecting a date by the user.<br />
<br />
TimePickerDialog: This dialog box is used for selecting <span class="ilad"><span id="IL_AD3">time by</span></span> the user.</div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b>How to Remove <span id="IL_AD3" style="font-weight: normal !important;"><span class="ilad">Desktop icons</span></span> and Widgets?</b></div>
<div class="MsoNormal">
Press and Hold the icon or widget. The phone will vibrate and on the bottom of the phone you will see an option to remove. While still holding the icon or widget <span class="ilad"><span id="IL_AD9">drag</span></span> it to the remove <span class="ilad"><span id="IL_AD10">button</span></span>. Once remove <span class="ilad"><span id="IL_AD5" style="font-weight: bold !important;">turns</span></span> red drop the item and it is gone</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 12pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Common Tricky questions</span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;"></span></div>
<ul style="line-height: 1.4; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Remember that the GUI layer doesn't request data directly from the web; data is always loaded from a local database.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The service layer periodically updates the local database.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is the risk in blocking the Main thread when performing a lengthy operation such as web access or heavy computation? Application_Not_Responding exception will be thrown which will crash and restart the application.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Why is List View not recommended to have active components? Clicking on the active text box will pop up the software keyboard but this will resize the list, removing focus from the clicked element.</span></li>
</ul>
<div class="MsoNormal">
<b><span style="font-size: 12pt; line-height: 18px;">For senior employees</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 12pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Beyond a certain level of experience, the job interview questions cease to be "difference between abstract class and interface", and focus more on testing your technical acumen, collaboration and communication skills. A list of such questions, typically asked during interviews for senior positions is given below:</span></div>
<ul style="line-height: 1.4; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Explain the life cycle of an application development process you worked on previously.<br />
<i>What the interviewer looks for is communication of requirements, planning, modeling, construction and deployment on the back end.</i></span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Here's a hypothetical project. Explain how you would go about it.<br />
<i>They want to know how you would break your work down into tasks and how many weeks for each task. I'm really looking to find out about planning methods, their skill set and how quickly they can execute.</i></span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you respond to requirement changes in the middle of a cycle?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What type of methodology have you used in the past? What are its drawbacks?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What are different techniques for prototyping an application?<br />
Similar question: Do you feel there is value in wireframing an application? Why?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you manage conflicts in Web applications when there are different people managing data?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Tell me something you learned from a team member in the last year.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What software testing procedures have you used to perform a QA?</span></li>
</ul>
<div class="MsoNormal" style="line-height: normal;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Once the coding skills verified. Sample I</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The Activity life cycle is must. Ask about the different phases of Activity Life cycle. For example: when and how the activity comes to foreground?</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Check the knowledge on AndroidManifest file, For example: Why do we need this file, What is the role of this file in Android app development.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Different Kinds of Intents</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about different Kinds of context</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about different Storage Methods in android</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Kinds of Log debugger and Debugger Configuration</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to debug the application on real device.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you ensure that the app design will be consistent across the different screen resolutions</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Thread concepts also plus points as we deal with the treads more.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Can you able to build custom views and how?</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to create flexible layouts, For example to place English, Chinese fonts.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is localization and how to achieve?</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What are 9-patch images</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to avoid ANR status</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to do Memory management</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about IPC</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is onCreate(<b>Bundle savedInstanceState</b>), Have you used savedInstanceState when and why?</span></div>
<div class="MsoNormal" style="line-height: normal; margin-left: 1in; text-indent: -0.25in;">
<span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">To check how updated the person is just ask about what are Fragments in an Activity</span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="line-height: normal;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">If this is an Android specific job, just ask the obvious stuff. Sample II</span></b></div>
<ul style="line-height: 1.4; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Application lifecycle</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">When to use a service</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to use a broadcast receiver and register it both in the manifest and in code</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Intent filters</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Stuff about what manifest attributes and tags mean</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The types of flags to run an application</span></li>
<ul style="line-height: 1.4; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;" type="circle">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">FLAG_ACTIVITY_NEW_TASK</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">FLAG_ACTIVITY_CLEAR_TOP</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">etc</span></li>
</ul>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to do data intensive calculations using threads</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Passing large objects (that can't be passed via intents and shouldn't be serialized) via a service</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Binding to a service and the service lifecycle</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to persist data (both savedInstanceState and more permanent ways)</span></li>
</ul>
</div>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com5tag:blogger.com,1999:blog-5778662197868112639.post-28326650118755862892012-11-16T17:02:00.002+05:302012-11-16T17:05:42.872+05:30Sign android application (apk.)<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 itemprop="name" style="text-align: left;">
<span style="color: #0b5394;">Signing Your Applications using eclipse, ant, console</span></h3>
<h3 itemprop="name" style="text-align: left;">
<span style="color: #0b5394;"> </span></h3>
The Android system requires that all installed applications be digitally signed with a
certificate whose private key is held by the application's developer. The Android system uses the
certificate as a means of identifying the author of an application and establishing trust
relationships between applications. The certificate is not used to control which applications the
user can install. The certificate does not need to be signed by a certificate authority: it is
perfectly allowable, and typical, for Android applications to use self-signed certificates.<br />
The important points to understand about signing Android applications are:<br />
<ul>
<li>All applications <i>must</i> be signed. The system will not install an application
on an emulator or a device if it is not signed.</li>
<li>To test and debug your application, the build tools sign your application with a special debug
key that is created by the Android SDK build tools.</li>
<li>When you are ready to release your application for end-users, you must sign it with a suitable
private key. You cannot publish an application that is signed with the debug key generated
by the SDK tools.</li>
<li>You can use self-signed certificates to sign your applications. No certificate authority is
needed.</li>
<li>The system tests a signer certificate's expiration date only at install time. If an
application's signer certificate expires after the application is installed, the application
will continue to function normally.</li>
<li>You can use standard tools — Keytool and Jarsigner — to generate keys and
sign your application <code>.apk</code> files.</li>
<li>After you sign your application for release, we recommend that you use the
<code>zipalign</code> tool to optimize the final APK package.</li>
</ul>
The Android system will not install or run an application that is not signed appropriately. This
applies wherever the Android system is run, whether on an actual device or on the emulator.
For this reason, you must <a href="http://developer.android.com/tools/publishing/app-signing.html#setup">set up signing</a> for your application before you can
run it or debug it on an emulator or device.<br />
<br />
<h3 id="signing" style="color: #4c1130; margin-bottom: 0px; text-align: left;">
Signing Process</h3>
<h3 id="signing" style="color: #4c1130; margin-bottom: 0px; text-align: left;">
</h3>
<hr />
The Android build process signs your application differently depending on which build mode you
use to build your application. There are two build modes: <i>debug mode</i> and <i>release
mode</i>. You use debug mode when you are developing and testing your application. You use
release mode when you want to build a release version of your application that you can
distribute directly to users or publish on an application marketplace such as Google Play.<br />
When you build in <i>debug mode</i> the Android SDK build tools use the Keytool utility
(included in the JDK) to create a debug key. Because the SDK build tools created the debug key,
they know the debug key's alias and password. Each time you compile your application in debug mode,
the build tools use the debug key along with the Jarsigner utility (also included in the JDK) to
sign your application's <code>.apk</code> file. Because the alias and password are known to the SDK
build tools, the tools don't need to prompt you for the debug key's alias and password each time
you compile.<br />
When you build in <i>release mode</i> you use your own private key to sign your application. If
you don't have a private key, you can use the Keytool utility to create one for you. When you
compile your application in release mode, the build tools use your private key along with the
Jarsigner utility to sign your application's <code>.apk</code> file. Because the certificate and
private key you use are your own, you will have to provide the password for the keystore and key
alias.<br />
The debug signing process happens automatically when you run or debug your application using
Eclipse with the ADT plugin. Debug signing also happens automatically when you use the Ant build
script with the <code>debug</code> option. You can automate the release signing process by using the
Eclipse Export Wizard or by modifying the Ant build script and building with the
<code>release</code> option.<br />
<br />
<br />
<br />
<h4 style="text-align: left;">
<span style="color: #4c1130;">Through Command line: </span></h4>
<h4 style="text-align: left;">
<span style="color: #4c1130;"> </span></h4>
<div class="post-text" style="text-align: left;">
use this command, (go to java < jdk < bin path in cmd prompt)
write the command<br />
<div class="default prettyprint prettyprinted" style="text-align: left;">
<b><code><span class="pln">$ jarsigner </span><span class="pun">-</span><span class="pln">verify </span><span class="pun">-</span><span class="pln">verbose </span><span class="pun">-</span><span class="pln">certs my_application</span><span class="pun">.</span><span class="pln">apk</span></code></b></div>
<div class="default prettyprint prettyprinted" style="text-align: left;">
<br /></div>
If you see "CN=Android Debug", this means the .apk was signed with the debug key generated by the Android SDK
(means it is unsigned), else u will find something for CN.
for more details<br />
<a href="http://developer.android.com/guide/publishing/app-signing.html" rel="nofollow">http://developer.android.com/guide/publishing/app-signing.html</a><br />
<br />
<br />
<h4 style="text-align: left;">
<span style="color: #4c1130;">if you are eclipse User</span></h4>
<h4 style="text-align: left;">
<span style="color: #4c1130;"> </span></h4>
Right-click your project in Eclipse > Chose <b>Android Tool</b> > <b>Export Signed Application Package.</b><br />
<br />
<br />
<h4 style="color: #4c1130; text-align: left;">
if you are Ant User </h4>
<h4 style="color: #4c1130; text-align: left;">
</h4>
<div class="post-text">
If you have ant version < 1.8.3 (ant -version) try this approach for issue with JDK 7 basing previous answer.<br />
<ol>
<li>Add signjarjdk7 to ANDROID_SDK\tools\ant\build.xml<br />
<pre class="lang-xml prettyprint prettyprinted"><code><span class="tag"><macrodef</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"signjarjdk7"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"jar"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"signedjar"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"keystore"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"storepass"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"alias"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"keypass"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><attribute</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"verbose"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><sequential></span><span class="pln">
</span><span class="tag"><exec</span><span class="pln"> </span><span class="atn">executable</span><span class="pun">=</span><span class="atv">"jarsigner"</span><span class="pln"> </span><span class="atn">failonerror</span><span class="pun">=</span><span class="atv">"true"</span><span class="tag">></span><span class="pln">
</span><span class="com"><!-- magic key, always verbose --></span><span class="pln">
</span><span class="tag"><arg</span><span class="pln"> </span><span class="atn">line</span><span class="pun">=</span><span class="atv">"-verbose -digestalg SHA1 -sigalg MD5withRSA"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><arg</span><span class="pln"> </span><span class="atn">line</span><span class="pun">=</span><span class="atv">"-keystore @{keystore} -storepass @{storepass} -keypass @{keypass}"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><arg</span><span class="pln"> </span><span class="atn">line</span><span class="pun">=</span><span class="atv">"-signedjar &quot;@{signedjar}&quot;"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"><arg</span><span class="pln"> </span><span class="atn">line</span><span class="pun">=</span><span class="atv">"&quot;@{jar}&quot; @{alias}"</span><span class="pln"> </span><span class="tag">/></span><span class="pln">
</span><span class="tag"></exec></span><span class="pln">
</span><span class="tag"></sequential></span><span class="pln">
</span><span class="tag"></macrodef></span></code></pre>
</li>
<li>Replace <code>'signjar'</code> to <code>'signjarjdk7'</code> in <code>'release'</code> target in the same build.xml.</li>
</ol>
NOTE: You have to define <b>'key.store.password'</b> and <b>'key.alias.password'</b> propeties for your project (in project.properties or in local.properties).<br />
Update<b>:</b><br />
If your have installed ant-1.8.3+ you have better solution:<br />
Open you ANDROID_SDK\tools\ant\build.xml and add two new parameters - sigalg and digestalg - in original 'signjar' invocation:<br />
<pre class="lang-xml prettyprint prettyprinted"><code><span class="pln"> </span><span class="tag"><signjar</span><span class="pln">
</span><span class="atn">sigalg</span><span class="pun">=</span><span class="atv">"MD5withRSA"</span><span class="pln">
</span><span class="atn">digestalg</span><span class="pun">=</span><span class="atv">"SHA1"</span><span class="pln">
</span><span class="atn">jar</span><span class="pun">=</span><span class="atv">"${out.packaged.file}"</span><span class="pln">
</span><span class="atn">signedjar</span><span class="pun">=</span><span class="atv">"${out.unaligned.file}"</span><span class="pln">
</span><span class="atn">keystore</span><span class="pun">=</span><span class="atv">"${key.store}"</span><span class="pln">
</span><span class="atn">storepass</span><span class="pun">=</span><span class="atv">"${key.store.password}"</span><span class="pln">
</span><span class="atn">alias</span><span class="pun">=</span><span class="atv">"${key.alias}"</span><span class="pln">
</span><span class="atn">keypass</span><span class="pun">=</span><span class="atv">"${key.alias.password}"</span><span class="pln">
</span><span class="atn">verbose</span><span class="pun">=</span><span class="atv">"${verbose}"</span><span class="pln"> </span><span class="tag">/></span></code></pre>
</div>
<br />
<br />
OR<br />
<h4 style="color: #4c1130; text-align: left;">
Signing application automatically with password in ant :</h4>
<h4 style="color: #4c1130; text-align: left;">
</h4>
<div class="post-text">
I just have these lines in my ant.properties and it signs automatically<br />
<pre class="lang-xml prettyprint prettyprinted"><code><span class="pln">key.store.password=mypasswordOne
key.alias.password=mypasswordTwo
key.store=c:/users/myname/my-release-key.keystore
key.alias=release_alias</span></code></pre>
<pre class="lang-xml prettyprint prettyprinted"><code><span class="pln"> </span></code></pre>
<h4 id="debugexpiry" style="color: #4c1130; text-align: left;">
Expiry of the Debug Certificate</h4>
<h4 id="debugexpiry" style="color: #4c1130; text-align: left;">
</h4>
The self-signed certificate used to sign your application in debug mode (the default on
Eclipse/ADT and Ant builds) will have an expiration date of 365 days from its creation date.<br />
When the certificate expires, you will get a build error. On Ant builds, the error
looks like this:<br />
<span class="pln">debug</span><span class="pun">:</span><span class="pln">
</span><span class="pun">[</span><span class="pln">echo</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Packaging</span><span class="pln"> bin</span><span class="pun">/</span><span class="pln">samples</span><span class="pun">-</span><span class="pln">debug</span><span class="pun">.</span><span class="pln">apk</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> signing it </span><span class="kwd">with</span><span class="pln"> a debug key</span><span class="pun">...</span><span class="pln">
</span><span class="pun">[</span><span class="kwd">exec</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Debug</span><span class="pln"> </span><span class="typ">Certificate</span><span class="pln"> expired on </span><span class="lit">8</span><span class="pun">/</span><span class="lit">4</span><span class="pun">/</span><span class="lit">08</span><span class="pln"> </span><span class="lit">3</span><span class="pun">:</span><span class="lit">43</span><span class="pln"> PM</span>
In Eclipse/ADT, you will see a similar error in the Android console.<br />
To fix this problem, simply delete the <code>debug.keystore</code> file.
The default storage location for AVDs is in <code>~/.android/</code> on OS X and Linux,
in <code>C:\Documents and Settings\<user>\.android\</code> on Windows XP, and in
<code>C:\Users\<user>\.android\</code> on Windows Vista and Windows 7.<br />
The next time you build, the build tools will regenerate a new keystore and debug key.<br />
Note that, if your development machine is using a non-Gregorian locale, the build
tools may erroneously generate an already-expired debug certificate, so that you get an
error when trying to compile your application. For workaround information, see the
troubleshooting topic <a href="http://developer.android.com/resources/faq/troubleshooting.html#signingcalendar">
I can't compile my app because the build tools generated an expired debug
certificate</a>. <br />
<pre class="lang-xml prettyprint prettyprinted"><code><span class="pln"> </span></code></pre>
</div>
<h4 style="color: #4c1130; text-align: left;">
</h4>
<br />
<br /></div>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-1959784675487971812012-11-16T16:07:00.000+05:302012-11-16T16:10:59.373+05:30Android Receive SMS Using Broadcast Receiver<div dir="ltr" style="text-align: left;" trbidi="on">
<h4 class="default prettyprint prettyprinted" style="text-align: left;">
<b><code><span class="kwd"> </span></code></b></h4>
<h4 class="default prettyprint prettyprinted" style="text-align: left;">
<b><code><span class="kwd"></span></code></b><b style="color: #4c1130;">The first are permissions . The application must receive, from the database. </b><b style="color: #4c1130;"> </b></h4>
<h4 class="default prettyprint prettyprinted" style="color: #4c1130; text-align: left;">
<b> Permissions can be <code>set in Manifest.xml like:</code></b><b><code class="cpp plain"></code></b></h4>
<h4 class="default prettyprint prettyprinted" style="color: #4c1130; text-align: left;">
<b><code class="cpp plain"> <uses-permission android:name=</code><code class="cpp string">"android.permission.RECEIVE_SMS"</code> <code class="cpp plain">/></code></b><b><code><span class="kwd"> </span></code></b></h4>
<h3 class="default prettyprint prettyprinted" style="text-align: left;">
<b><code><br /></code></b></h3>
<h3 class="default prettyprint prettyprinted" style="text-align: left;">
<b><code><span class="kwd"><span style="color: #4c1130;">Now our Activity class SMSreceiver is here... </span></span></code></b></h3>
<pre class="default prettyprint prettyprinted"><code><span class="kwd">private</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">SMSreceiver</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">BroadcastReceiver</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
</span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> TAG </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">getClass</span><span class="pun">().</span><span class="pln">getSimpleName</span><span class="pun">();</span><span class="pln">
</span><span class="lit">@Override</span><span class="pln">
</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onReceive</span><span class="pun">(</span><span class="typ">Context</span><span class="pln"> context</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Intent</span><span class="pln"> intent</span><span class="pun">)</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
</span><span class="typ">Bundle</span><span class="pln"> extras </span><span class="pun">=</span><span class="pln"> intent</span><span class="pun">.</span><span class="pln">getExtras</span><span class="pun">();</span><span class="pln">
</span><span class="typ">String</span><span class="pln"> strMessage </span><span class="pun">=</span><span class="pln"> </span><span class="str">""</span><span class="pun">;</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> extras </span><span class="pun">!=</span><span class="pln"> </span><span class="kwd">null</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
</span><span class="typ">Object</span><span class="pun">[]</span><span class="pln"> smsextras </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Object</span><span class="pun">[])</span><span class="pln"> extras</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="pln"> </span><span class="str">"pdus"</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
</span><span class="kwd">for</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> i </span><span class="pun"><</span><span class="pln"> smsextras</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
</span><span class="typ">SmsMessage</span><span class="pln"> smsmsg </span><span class="pun">=</span><span class="pln"> </span><span class="typ">SmsMessage</span><span class="pun">.</span><span class="pln">createFromPdu</span><span class="pun">((</span><span class="kwd">byte</span><span class="pun">[])</span><span class="pln">smsextras</span><span class="pun">[</span><span class="pln">i</span><span class="pun">]);</span><span class="pln">
</span><span class="typ">String</span><span class="pln"> strMsgBody </span><span class="pun">=</span><span class="pln"> smsmsg</span><span class="pun">.</span><span class="pln">getMessageBody</span><span class="pun">().</span><span class="pln">toString</span><span class="pun">();</span><span class="pln">
</span><span class="typ">String</span><span class="pln"> strMsgSrc </span><span class="pun">=</span><span class="pln"> smsmsg</span><span class="pun">.</span><span class="pln">getOriginatingAddress</span><span class="pun">();</span><span class="pln"> </span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln"> strMessage </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"SMS from "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> strMsgSrc </span><span class="pun">+</span><span class="pln"> </span><span class="str">" : "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> strMsgBody</span><span class="pun">;</span><span class="pln">
</span><span class="typ">Log</span><span class="pun">.</span><span class="pln">i</span><span class="pun">(</span><span class="pln">TAG</span><span class="pun">,</span><span class="pln"> strMessage</span><span class="pun">);</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-1171452302287139172012-10-18T17:52:00.001+05:302012-10-18T17:52:28.562+05:30MapView Tutorial<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="page-title" itemprop="name" style="text-align: left;">
MapView Tutorial</h3>
Using the Google Maps library, you can create your own map-viewing Activity. In this
tutorial, you'll create a simple map application in two parts. In Part 1, you'll create an app
that shows a map the user can pan and zoom. In Part 2, you'll add overlay items that mark
points of interest.
<br />
<div class="special">
This tutorial requires that you have the external Google Maps library
installed in your SDK environment. The Maps library is included with the Google APIs
add-on, which you can install using the Android SDK and
AVD Manager. To learn how, see
<a href="http://developers.google.com/android/add-ons/google-apis/installing">
Installing the Google APIs Add-On</a>.
<br />
After installing the Google APIs add-on in your SDK, set your project properties to use the
build target called "Google APIs by Google Inc.". See the instructions for setting a build
target in
<a href="http://developer.android.com/guide/developing/projects/projects-eclipse.html#CreatingAProject">
Creating and Managing Projects in Eclipse</a> or
<a href="http://developer.android.com/guide/developing/projects/projects-cmdline.html#CreatingAProject">
Creating and Managing Projects on the Command Line</a>, as appropriate for your environment.
<br />
You will also need to set up a new AVD that uses the same Google APIs deployment target. See
<a href="http://developer.android.com/guide/developing/devices/index.html">
Creating and Managing Virtual Devices</a> for more information.
<br />
For reference material, see the
<a href="https://developers.google.com/maps/documentation/android/reference/index.html">
Google Maps library documentation</a>.
<br />
</div>
<h4 style="text-align: left;">
Part 1: Creating a Map Activity</h4>
<ol>
<li>Start a new project named <em>HelloGoogleMaps</em>.</li>
<li>
Because the Maps library is not a part of the standard Android library, you must
declare it in the Android Manifest. Open the <code>AndroidManifest.xml</code>
file and add the following as a child of the <code><application></code> element:
<pre><uses-library android:name="com.google.android.maps"/></pre>
</li>
<li>
You also need access to the Internet in order to retrieve map tiles,
so you must also request the
<code><a href="http://developer.android.com/reference/android/Manifest.permission.html#INTERNET">INTERNET</a></code>
permission. In the manifest file, add the following as a child of the
<code><manifest></code> element:
<pre><uses-permission android:name="android.permission.INTERNET"/></pre>
</li>
<li>
While you're in the manifest, give the map some more space by getting rid of the title bar
with the "NoTitleBar" theme:
<pre><activity android:name=".HelloGoogleMaps" android:label="@string/app_name"
<strong>android:theme="@android:style/Theme.NoTitleBar"</strong>>
</pre>
</li>
<li>
Open the <code>res/layout/main.xml</code> file and add a single
<code><a href="http://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapView.html">MapView</a></code>
as the root node:
<pre><?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="<em>Your Maps API Key goes here</em>"
/>
</pre>
The <code>android:clickable</code> attribute defines whether you want to allow
user-interaction with the map. If this is "false" then touching the map does nothing.
<br />
The <code>android:apiKey</code> attribute holds the Maps API Key for your
application, which proves your application and signer certificate has been registered with
the Maps service. This is required in order to receive the map data, even while you are
developing. Registration to the service is free and it only takes a couple
minutes to register your certificate and get a Maps API Key.
<br />
Go now to get a key. For instructions, read
<a href="https://developers.google.com/maps/documentation/android/mapkey.html">
Obtaining a Maps API Key</a>. For the purpose of this tutorial, you should
register with the SDK debug certificate, as described in
<a href="https://developers.google.com/maps/documentation/android/mapkey#getdebugfingerprint">
Getting the MD5 Fingerprint of the SDK Debug Certificate</a>. Please note that this
is only valid while your application is signed with the debug key; once you sign with your
private key, you will need a new API key. When you get your key, insert it for the value of
<code>android:apiKey</code>.<br />
</li>
<li>
Now open the <code>HelloGoogleMaps.java</code> file. For this Activity,
extend <code>MapActivity</code> instead of <code>android.app.Activity</code>:
<pre>public class HelloGoogleMaps extends MapActivity</pre>
<code><a href="https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapActivity.html">MapActivity</a></code>
is a special sub-class of
<code><a href="http://developer.android.com/reference/android/app/Activity.html">Activity</a></code>,
provided by the Maps library, which provides important map capabilities.
<br />
</li>
<li>
Inside every <code>MapActivity</code>, the <code>isRouteDisplayed()</code> method is
required, so override this method:
<pre>@Override
protected boolean isRouteDisplayed() {
return false;
}
</pre>
This method is required for some accounting from the Maps service to see if you're
currently displaying any route information. In this case, you're not, so return false.
<br />
</li>
<li>
Now add the standard
<code><a href="http://developer.android.com/reference/android/app/Activity.html#onCreate%28android.os.Bundle%29">onCreate()</a></code>
callback method to the class:
<pre>@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
</pre>
This loads the layout file created above. In fact, this is now a workable application that will
display map tiles and allow the user to pan around the map. But there's no ability to zoom.
Fortunately, there's a very simple zoom feature built into the <code>MapView</code> class,
which you can include by calling <code>setBuiltInZoomControls()</code>. Do this at the end of
the
<code><a href="http://developer.android.com/reference/android/app/Activity.html#onCreate%28android.os.Bundle%29">onCreate()</a></code>
method definition:<br />
<pre> MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
</pre>
</li>
<li>
That's all there is to it. Run the application. Remember, you must have an
<a href="http://developer.android.com/guide/developing/devices/index.html">AVD</a>
configured to use the Google APIs target, or be using a development device that includes the
Maps library.
</li>
</ol>
<h4 style="text-align: left;">
Part 2: Adding Overlay Items</h4>
So, now you have a map, but in many cases you'll also want to create your own map
markers and lay-overs. That's what you'll do now. In order to do so, you must implement the
<code>ItemizedOverlay</code> class, which can manage a whole set of <code>Overlay</code> objects
(the individual items placed on the map).
<br />
<ol>
<li>
Create a new Java class named <code>HelloItemizedOverlay</code> that extends
<code>ItemizedOverlay</code>:
When using Eclipse, right-click the package name in the Eclipse Package Explorer, and
select <strong>New > Class</strong>. Set the <strong>Name</strong>
field to <em>HelloItemizedOverlay</em>. For <strong>Superclass</strong>, enter
<em>"com.google.android.maps.ItemizedOverlay</em>. Click the checkbox for
<em>Constructors from superclass</em>. Click <em>Finish</em>.
<br />
</li>
<li>
First, you need an <code>OverlayItem</code>
<a href="http://developer.android.com/reference/java/util/ArrayList.html">ArrayList</a>, in
which you'll put each of the <code>OverlayItem</code> objects you want on the map. Add this
at the top of the <code>HelloItemizedOverlay</code> class:
<pre>private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();</pre>
</li>
<li>
Now define the <code>HelloItemizedOverlay</code> constructors. The constructor must
define the default marker for each of the <code>OverlayItem</code> objects. In order for
the <code><a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html">Drawable</a></code>
to actually get drawn, it must have its bounds defined. Most
commonly, you want the center-point at the bottom of the image to be the point at which it's
attached to the map coordinates. This is handled for you with the
<code>boundCenterBottom()</code> method. Wrap this around the <code>defaultMarker</code>,
so the super constructor call looks like this:
<pre>public HelloItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
</pre>
</li>
<li>
In order to add new <code>OverlayItem</code> objects to the <code>ArrayList</code>, you
need a new method:
<pre>public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}</pre>
Each time you add a new <code>OverlayItem</code> to the <code>ArrayList</code>, you must
call <code>populate()</code> for the <code>ItemizedOverlay</code>, which will read each
of the <code>OverlayItem</code> objects and prepare them to be drawn.
<br />
</li>
<li>
When the <code>populate()</code> method executes, it will call <code>createItem(int)</code>
in the <code>ItemizedOverlay</code> to retrieve each <code>OverlayItem</code>. You must
override this method to properly read from the ArrayList and return the
<code>OverlayItem</code> from the position specified by the given integer. Your override
method should look like this:
<pre>@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
</pre>
</li>
<li>
You must also override the <code>size()</code> method to return the current number of
items in the ArrayList:
<pre>@Override
public int size() {
return mOverlays.size();
}
</pre>
</li>
<li>
Now set up the ability to handle touch events on the overlay items. First, you're
going to need a reference to the application
<code><a href="http://developer.android.com/reference/android/content/Context.html">Context</a></code>
as a member of this class. So add <code>Context mContext</code> as a class member, then
initialize it with a new class constructor:
<pre>public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
</pre>
This passes the <code>defaultMarker</code> up to the default constructor to bound its
coordinates and then initializes <code>mContext</code> with the given
<code><a href="http://developer.android.com/reference/android/content/Context.html">Context</a></code>.
<br />
Then override the <code>onTap()</code> callback method, which will handle the event
when an item is tapped by the user:
<br />
<pre>@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
</pre>
This uses the member <code>android.content.Context</code> to create a new
<code><a href="http://developer.android.com/reference/android/app/AlertDialog.Builder.html">AlertDialog.Builder</a></code>
and uses the tapped <code>OverlayItem</code>'s title and snippet for
the dialog's title and message text. (You'll see the <code>OverlayItem</code> title and
snippet defined when you create it below.)
<br />
</li>
</ol>
You're now done with the <code>HelloItemizedOverlay</code> class and can start using it
to add items on the map.
<br />
Go back to the <code>HelloGoogleMaps</code> class. In the following procedure, you'll create an
<code>OverlayItem</code> and add it to an instance of the <code>HelloItemizedOverlay</code>
class, then add the <code>HelloItemizedOverlay</code> to the <code>MapView</code> using a
<code>GeoPoint</code> to define its coordinates on the map.
<br />
<img align="right" src="https://developers.google.com/maps/documentation/android/images/androidmarker.png" />
<ol>
<li>
First, you need the image for the map overlay. If you don't have one handy, use the
Android on the right. Drag this image (or your own) into the <code>res/drawable/</code>
directory of your project.
</li>
<li>
At the end of your existing <code>onCreate()</code> method, instantiate :
<pre>List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);
</pre>
All overlay elements on a map are held by the <code>MapView</code>, so when you want to
add some, you have to get a list from the <code>getOverlays()</code> method. Then
instantiate the
<code><a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html">Drawable</a></code>
used for the map marker, which was saved in the <code>res/drawable/</code> directory.
The constructor for <code>HelloItemizedOverlay</code> (your custom
<code>ItemizedOverlay</code>) takes the Drawable in order to set the default marker for
all overlay items.
<br />
</li>
<li>
Now create a <code>GeoPoint</code> that defines the map coordinates for the first overlay
item, and pass it to a new {@code OverlayItem}:
<pre>GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
</pre>
<code>GeoPoint</code> coordinates are specified in microdegrees
(<code>degrees * 1e6</code>). The <code>OverlayItem</code> constructor accepts the
<code>GeoPoint</code> location, a string for the item's title, and a string for the
item's snippet text, respectively.
<br />
</li>
<li>
All that's left is to add this <code>OverlayItem</code> to your collection in the
<code>HelloItemizedOverlay</code> instance, then add the <code>HelloItemizedOverlay</code>
to the MapView:
<pre>itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
</pre>
</li>
<li>Now run the application.</li>
</ol>
You should see the following:
<br />
<img src="https://developers.google.com/maps/documentation/android/images/hello-mapview.png" width="150px" />
When you tap the overlay item, you'll see the dialog appear.
<br />
Because the <code>ItemizedOverlay</code> class uses an <code>java.util.ArrayList</code> for all
of the <code>OverlayItem</code> objects, it's easy to add more. Try adding another one. Before
the <code>addOverlay()</code> method is called, add these lines:<br />
<pre>GeoPoint point2 = new GeoPoint(35410000, 139460000);
OverlayItem overlayitem2 = new OverlayItem(point2, "Sekai, konichiwa!", "I'm in Japan!");
</pre>
</div>
Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-56840574407166134322012-06-15T11:26:00.001+05:302012-06-15T11:41:37.812+05:30How to Install Windows 95, 98, XP on Android Phone<div dir="ltr" style="text-align: left;" trbidi="on">
<b></b><br />
<br />
<h3 style="text-align: left;">
</h3>
Have you always wanted to use <strong>Windows or Linux on your smartphone</strong>? Then you are right, because today we want to tell you about a fantastic app that allows to do this.<br />
The application was created by a developer at XDA and called Bochs
Pentium emulator, its inventor says that operating systems are tested
and working for Windows95.98, XP and some distributions Linux, tested on
smartphone Android HTC Evo 3D. <br />
<h3 style="text-align: left;">
<u><span style="color: #4c1130;">1st Idea :</span></u></h3>
<b><i> HTC EVO 3D or You can try this on another android phones.</i></b><br />
<br />
<i>Pre-requisites: </i>Windows 95/98/XP Image: ISO or .IMG. (IMG preferred and tested).<br />
<br />
<b>Step 1. </b>Download <a href="http://forum.xda-developers.com/attachment.php?attachmentid=814993&d=1323778011" target="_blank">bochs.apk</a> [<a href="http://geeknizer.com/download/Bochs2_5_1.apk">mirror</a>] and <a href="http://forum.xda-developers.com/attachment.php?attachmentid=814994&d=1323778011" target="_blank">SDL.zip</a> [<a href="http://geeknizer.com/download/SDL.zip">mirror</a>]. Put SDL.zip on root of sdcard/<br />
<br />
<b>Step 2.</b> Put the Windows 95/98/XP disk image .img/.iso
[(need to change setting in bochsrc.txt accordingly (iso not tested
yet)] of any operating system in SDL folder and rename it to “c.img”.<br />
<br />
<b>Step 3.</b> Run Bochs apk. Let it boot (takes a while) and enjoy.<br />
<br />
<b>Note</b>: Use <a href="http://forum.xda-developers.com/attachment.php?attachmentid=871412&d=1327474852" target="_blank">this bochsrc.txt</a>
to use a folder called “HDD” on your sdcard as a drive in windows.
Replace the original bochsrc.txt withthe one stated before. Further
updates on xda <a href="http://forum.xda-developers.com/showthread.php?t=1459153" target="_blank">thread</a>.<br />
Instructions for input controls are as follows:<br />
<ul>
<li>To emulate touchpad on touchscreen and left/right mouse buttons on volume</li>
<li>You can also click touch screen to generate mouse left button click.(this does not work everytime)</li>
<li>Back = BackSpace, Menu = Enter, left-upper corner click generates TAB</li>
<li>left-lower corner click popups keyboard</li>
</ul>
<div style="background-color: white; border: medium none; color: black; overflow: hidden; text-align: left; text-decoration: none;">
<br /></div>
<div style="background-color: white; border: medium none; color: black; overflow: hidden; text-align: left; text-decoration: none;">
<u><br /></u></div>
<h3 style="text-align: left;">
<u><span style="color: #4c1130;">2st Idea For All Android Phones :</span></u></h3>
<br />
<object style="height: 390px; width: 640px;"><param name="movie" value="http://www.youtube.com/v/EUE-gJmcGKk?version=3&feature=player_detailpage">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed src="http://www.youtube.com/v/EUE-gJmcGKk?version=3&feature=player_detailpage" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></object><br />
<br />
<br />
<h3 style="text-align: left;">
<u><span style="color: #4c1130;">3rd Idea For All Android Phones :</span></u></h3>
<br />
<strong></strong><br />
The first thing to do is downloading of the file to install apk files and SD from the following links:<br />
<a href="http://forum.xda-developers.com/attachment.php?attachmentid=879821&d=1327954605">SDL.zip</a><br />
<a href="http://forum.xda-developers.com/attachment.php?attachmentid=879822&d=1327954605">SDLapp.apk</a><br />
Once downloaded, Extract the first zip, create a folder called SDL in
the root of the device and copy your files extracted from the first zip
file and apk by using Smartphone with Archive, ES File or any other
file manager, go to the directory created and started to install the
apk.<br />
<a href="http://androidlot.com/wp-content/uploads/2012/02/Windows-XP-on-Android.jpg"><img alt="Windows XP on Android" class="aligncenter size-full wp-image-573" height="300" src="http://androidlot.com/wp-content/uploads/2012/02/Windows-XP-on-Android.jpg" title="Windows XP on Android" width="180" /></a><br />
Once the installation process is finished, make the iso compatible
operating system such as XP, and then rename c.img, place it in the same
directory with SDL. Launch the app and have fun!<br />
Obviously launching a XP os is equivalent to consume lots of RAM and
space on your mobile device, but if you want to impress your friends
then this app is really for you.<br />
</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com6tag:blogger.com,1999:blog-5778662197868112639.post-85943272648119689652012-03-20T15:48:00.001+05:302012-03-20T15:59:03.967+05:30Android Styles and Themes<div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: #660000;">A <b>style</b></span> is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.<br />
Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.<br />
<br />
For<b style="color: #6fa8dc;"> example</b>, by using a style, you can take this layout XML:<br />
<br />
<TextView<br />
android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:textColor="#00FF00"<br />
android:typeface="monospace"<br />
android:text="@string/hello" /><br />
<br />
And turn it into this:<br />
<TextView<br />
style="@style/CodeFont"<br />
android:text="@string/hello" /><br />
<br />
All of the attributes related to style have been removed from the layout XML and put into a style definition called CodeFont, which is then applied with the style attribute. You'll see the definition for this style in the following section.<br />
<br />
A theme is a style applied to an entire Activity or application, rather than an individual View (as in the example above). When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports. For example, you can apply the same CodeFont style as a theme for an Activity and then all text inside that Activity will have green monospace font.<br />
Defining Styles<br />
<br />
To <span style="color: #3d85c6;">create a set of styles</span>, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder.<br />
The root node of the XML file must be <resources>.<br />
<br />
For each style you want to create, add a <style> element to the file with a name that uniquely identifies the style (this attribute is required). Then add an <item> element for each property of that style, with a name that declares the style property and a value to go with it (this attribute is required). The value for the <item> can be a keyword string, a hex color, a reference to another resource type, or other value depending on the style property. Here's an example file with a single style:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<resources><br />
<style name="CodeFont" parent="@android:style/TextAppearance.Medium"><br />
<item name="android:layout_width">fill_parent</item><br />
<item name="android:layout_height">wrap_content</item><br />
<item name="android:textColor">#00FF00</item><br />
<item name="android:typeface">monospace</item><br />
</style><br />
</resources><br />
<br />
Each child of the <resources> element is converted into an application resource object at compile-time, which can be referenced by the value in the <style> element's name attribute. This example style can be referenced from an XML layout as @style/CodeFont (as demonstrated in the introduction above).<br />
<br />
The parent attribute in the <style> element is optional and specifies the resource ID of another style from which this style should inherit properties. You can then override the inherited style properties if you want to.<br />
Remember, a style that you want to use as an Activity or application theme is defined in XML exactly the same as a style for a View. A style such as the one defined above can be applied as a style for a single View or as a theme for an entire Activity or application. How to apply a style for a single View or as an application theme is discussed later.<br />
Inheritance<br />
<br />
The parent attribute in the <style> element lets you specify a style from which your style should inherit properties. You can use this to inherit properties from an existing style and then define only the properties that you want to change or add. You can inherit from styles that you've created yourself or from styles that are built into the platform. (See Using Platform Styles and Themes, below, for information about inheriting from styles defined by the Android platform.) For example, you can inherit the Android platform's default text appearance and then modify it:<br />
<br />
<style name="GreenText" parent="@android:style/TextAppearance"><br />
<item name="android:textColor">#00FF00</item><br />
</style><br />
<br />
If you want to<b><span style="color: #990000;"> inherit </span></b>from styles that you've defined yourself, you do not have to use the parent attribute. Instead, just prefix the name of the style you want to inherit to the name of your new style, separated by a period. For example, to create a new style that inherits the CodeFont style defined above, but make the color red, you can author the new style like this:<br />
<style name="CodeFont.Red"><br />
<item name="android:textColor">#FF0000</item><br />
</style><br />
Notice that there is no parent attribute in the <style> tag, but because the name attribute begins with the CodeFont style name (which is a style that you have created), this style inherits all style properties from that style. This style then overrides the android:textColor property to make the text red. You can reference this new style as @style/CodeFont.Red.<br />
You can continue inheriting like this as many times as you'd like, by chaining names with periods. For example, you can extend CodeFont.Red to be bigger, with:<br />
<style name="CodeFont.Red.Big"><br />
<item name="android:textSize">30sp</item><br />
</style><br />
<br />
This inherits from both CodeFont and CodeFont.Red styles, then adds the android:textSize property.<br />
Note: This technique for inheritance by chaining together names only works for styles defined by your own resources. You can't inherit Android built-in styles this way. To reference a built-in style, such as TextAppearance, you must use the parent attribute.<br />
Style Properties<br />
<br />
Now that you understand how a style is defined, you need to learn what kind of style properties—defined by the <item> element—are available. You're probably familiar with some already, such as layout_width and textColor. Of course, there are many more style properties you can use.<br />
The best place to find properties that apply to a specific View is the corresponding class reference, which lists all of the supported XML attributes. For example, all of the attributes listed in the table of TextView XML attributes can be used in a style definition for a TextView element (or one of its subclasses). One of the attributes listed in the reference is android:inputType, so where you might normally place the android:inputType attribute in an <EditText> element, like this:<br />
<br />
<EditText<br />
android:inputType="number"<br />
... /><br />
You can instead create a style for the EditText element that includes this property:<br />
<style name="Numbers"><br />
<item name="android:inputType">number</item><br />
...<br />
</style><br />
So your XML for the layout can now implement this style:<br />
<EditText<br />
style="@style/Numbers"<br />
... /><br />
<br />
This simple example may look like more work, but when you add more style properties and factor-in the ability to re-use the style in various places, the pay-off can be huge.<br />
For a reference of all available style properties, see the R.attr reference. Keep in mind that all View objects don't accept all the same style attributes, so you should normally refer to the specific View class for supported style properties. However, if you apply a style to a View that does not support all of the style properties, the View will apply only those properties that are supported and simply ignore the others.<br />
<br />
Some style properties, however, are not supported by any View element and can only be applied as a theme. These style properties apply to the entire window and not to any type of View. For example, style properties for a theme can hide the application title, hide the status bar, or change the window's background. These kind of style properties do not belong to any View object. To discover these theme-only style properties, look at the R.attr reference for attributes that begin with window. For instance, windowNoTitle and windowBackground are style properties that are effective only when the style is applied as a theme to an Activity or application. See the next section for information about applying a style as a theme.<br />
<br />
<b style="color: #b45f06;">Note:</b> Don't forget to prefix the property names in each <item> element with the android: namespace. For example: <item name="android:inputType">.<br />
Applying Styles and Themes to the UI<br />
There are two ways to set a style:<br />
• To an individual View, by adding the style attribute to a View element in the XML for your layout.<br />
• Or, to an entire Activity or application, by adding the android:theme attribute to the <activity> or <application> element in the Android manifest.<br />
When you apply a style to a single View in the layout, the properties defined by the style are applied only to that View. If a style is applied to a ViewGroup, the child View elements will not inherit the style properties—only the element to which you directly apply the style will apply its properties. However, you can apply a style so that it applies to all View elements—by applying the style as a theme.<br />
<br />
To apply a style definition as a theme, you must apply the style to an Activity or application in the Android manifest. When you do so, every View within the Activity or application will apply each property that it supports. For example, if you apply the CodeFont style from the previous examples to an Activity, then all View elements that support the text style properties will apply them. Any View that does not support the properties will ignore them. If a View supports only some of the properties, then it will apply only those properties.<br />
Apply a style to a View<br />
Here's how to set a style for a View in the XML layout:<br />
<br />
<TextView<br />
style="@style/CodeFont"<br />
android:text="@string/hello" /><br />
Now this TextView will be styled as defined by the style named CodeFont. (See the sample above, in Defining Styles.)<br />
Note: The style attribute does not use the android: namespace prefix.<br />
Apply a theme to an Activity or application<br />
To set a theme for all the activities of your application, open the AndroidManifest.xml file and edit the <application> tag to include the android:theme attribute with the style name. For example:<br />
<application android:theme="@style/CustomTheme"><br />
<br />
If you want a theme applied to just one Activity in your application, then add the android:theme attribute to the <activity> tag instead.<br />
Just as Android provides other built-in resources, there are many pre-defined themes that you can use, to avoid writing them yourself. For example, you can use the Dialog theme and make your Activity appear like a dialog box:<br />
<br />
<activity android:theme="@android:style/Theme.Dialog"><br />
Or if you want the background to be transparent, use the Translucent theme:<br />
<activity android:theme="@android:style/Theme.Translucent"><br />
If you like a theme, but want to tweak it, just add the theme as the parent of your custom theme. For example, you can modify the traditional light theme to use your own color like this:<br />
<color name="custom_theme_color">#b0b0ff</color><br />
<style name="CustomTheme" parent="android:Theme.Light"><br />
<item name="android:windowBackground">@color/custom_theme_color</item><br />
<item name="android:colorBackground">@color/custom_theme_color</item><br />
</style><br />
<br />
(Note that the color needs to supplied as a separate resource here because the android:windowBackground attribute only supports a reference to another resource; unlike android:colorBackground, it can not be given a color literal.)<br />
Now use CustomTheme instead of Theme.Light inside the Android Manifest:<br />
<activity android:theme="@style/CustomTheme"><br />
<br />
Select a theme based on platform version<br />
Newer versions of Android have additional themes available to applications, and you might want to use these while running on those platforms while still being compatible with older versions. You can accomplish this through a custom theme that uses resource selection to switch between different parent themes, based on the platform version.<br />
<br />
For example, here is the declaration for a custom theme which is simply the standard platforms default light theme. It would go in an XML file under res/values (typically res/values/styles.xml): <br />
<style name="LightThemeSelector" parent="android:Theme.Light"><br />
...<br />
</style><br />
To have this theme use the newer holographic theme when the application is running on Android 3.0 (API Level 11) or higher, you can place an alternative declaration for the theme in an XML file in res/values-v11, but make the parent theme the holographic theme:<br />
<style name="LightThemeSelector" parent="android:Theme.Holo.Light"><br />
...<br />
</style><br />
<br />
Now use this theme like you would any other, and your application will automatically switch to the holographic theme if running on Android 3.0 or higher.<br />
A list of the standard attributes that you can use in themes can be found at R.styleable.Theme.<br />
For more information about providing alternative resources, such as themes and layouts, based on the platform version or other device configurations, see the Providing Resources document.<br />
Using Platform Styles and Themes<br />
<br />
The Android platform provides a large collection of styles and themes that you can use in your applications. You can find a reference of all available styles in the R.style class. To use the styles listed here, replace all underscores in the style name with a period. For example, you can apply the Theme_NoTitleBar theme with "@android:style/Theme.NoTitleBar".<br />
The R.style reference, however, is not well documented and does not thoroughly describe the styles, so viewing the actual source code for these styles and themes will give you a better understanding of what style properties each one provides. For a better reference to the Android styles and themes, see the following source code:<br />
• Android Styles (styles.xml)<br />
• Android Themes (themes.xml)<br />
<br />
These files will help you learn through example. For instance, in the Android themes source code, you'll find a declaration for <style name="Theme.Dialog">. In this definition, you'll see all of the properties that are used to style dialogs that are used by the Android framework.<br />
For more information about the syntax used to create styles in XML, see Available Resource Types: Style and Themes.<br />
<br />
For a reference of available style attributes that you can use to define a style or theme (e.g., "windowBackground" or "textAppearance"), see R.attr or the respective View class for which you are creating a style.</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-24157567428972097692012-03-19T15:51:00.002+05:302012-03-19T15:51:21.588+05:30Making the Android UI Fast and Efficient<object style="height: 390px; width: 640px"><param name="movie" value="http://www.youtube.com/v/UApv-ZMJ51g?version=3&feature=player_detailpage"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><embed src="http://www.youtube.com/v/UApv-ZMJ51g?version=3&feature=player_detailpage" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></object>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-91557273479612397802012-03-19T09:50:00.000+05:302012-03-19T09:50:30.670+05:30Efficient android programming Tips<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="color: #660000; line-height: normal;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">General Tips:</span></b></div><ol start="1" type="1"><li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Add Two Numbers:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Your first non-tutorial application should be to take two numbers and add them together. It sounds too simple. You will spend some hours getting the layouts, the callbacks, and onPause/onResume to work correctly. Do it.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">It is Java:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> You work in Java for most of your Android programming. Don't spend time praising it. Don't spend time complaining about it. Just work with it.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Love RelativeLayout:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Most of the tutorials use LinearLayout, but you will find that RelativeLayout is truly useful. Many layouts, like the GridLayout aren't used much at all. Play around with RelativeLayout. See an example from <a href="http://stackoverflow.com/questions/2990882/android-and-layouts/2991213#2991213">this question</a>.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use </span></b><b><span style="font-family: "Times New Roman","serif"; font-size: 10pt;">fill_parent</span></b><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> with a top level RelativeLayout:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> A surprisingly common and hard to find problem is putting a wrap_content in a top level RelativeLayout and then wondering why unrelated fields far down in the hierarchy are rendering strangely.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use empty layout items:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> You will often use empty items in your layouts just for positioning other layouts. For example, you might use an empty TextField, of width=0 and height=0 and centerInParent='True' just to anchor things relative to the middle of the screen. Also, you might have an empty TextField or LinearLayout so that you can give a layout_weight=1 to it and have it take up more screen space.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Set a layout background color:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> If you are having trouble figuring out your layout, try setting the background colors on some objects. It can highlight your mistakes faster than other tools, and shows some surprises that the IDE red box doesn't always help.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Download Apps-For-Android:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> This is a big chunk of useful source code for a half dozen applications. It can supplement the sample applications nicely and show different coding style solutions. Grab it using </span><span style="font-family: "Times New Roman","serif"; font-size: 10pt;">svn co <a href="http://apps-for-android.googlecode.com/svn/trunk/">http://apps-for-android.googlecode.com/svn/trunk/</a> apps-for-android-read-only</span><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"></span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Download the source:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> You need the Android source to solve some problems or, more likely, get past holes in the documentation. Your copy does not need to be perfect or kept up to date. You can learn to use the repo command, or just visit <a href="http://android.git.kernel.org/">http://android.git.kernel.org/</a> for a snapshot.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Learn to search your source:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> The fastest solution to many problems is to find where a particular parameter is used in some other source. Put a copy or link to the sample applications, apps-for-android applications, and any other source you have under one directory tree. Use "grep -ir funky_parameter sample_code/" or your favorite searching routine to quickly find some code that uses that parameter.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Eclipse:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Even you have a favorite editor or IDE you have used for years, use Eclipse for Android development. It is good enough as an IDE and is really part of the development tools suite. Any time you spend trying to jury-rig your IDE to work is time you didn't code. </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Learn Eclipse:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Learn a few new tricks with Eclipse every day. Some of my favorite commands were found reading <a href="http://eclipse.dzone.com/news/effective-eclipse-shortcut-key">this list</a> and <a href="http://stackoverflow.com/questions/54886/hidden-features-of-eclipse">this question</a>.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Get help when starting out:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> The quantity of readable material can be overwhelming. Setting up the environment can be tricky. Going to an Android Meet-up or users group can help get over the initial hump. </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Code every day:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Android code will be frustrating. Don't allow yourself to stop because you get stuck. Play around with the tools, step through a sample application, read one of the articles, or read a blog to ease the frustration. Then write some more code.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Lurk on IRC:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Connect your favorite IRC reader to irc.freenode.net's #android-dev channel. Leave it up in the background. Only ask questions after you have spent ten minutes trying to figure it out on your own.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use two monitors:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Working on your laptop in the coffee shop will slow you down. You need to spread out windows. At very least, you will want a full screen Eclipse session, the emulator, and a browser with the tutorial to all be easily visible. Three screens may work even better.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Reformat XML files:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> The layout editor makes a hash of the XML files. Use the 'source/format' command to put them in a reasonable form. You will want to check the "Eclipse/Windows/Preferences/XML/XML Files/Editor/Formatting/Split XML attributes each on a new line" check box. Then use shift-ctrl-F to format it.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Edit XML files with the text editor:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> After the first couple of layout screens, stop using the slow moving 'properties' gui to change properties. Drop the items using the gui. Use the up/down arrows on the far right outline to get the hierarchy of views and layouts correct, then edit the XML file directly and use the ctrl-space shortcut to bring up possible completions and explanations of the properties.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Plan on Piracy in the MarketPlace:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> Google has not made the MarketPlace a Happy Place. Apps are copied and reposted with changed names to funnel money around. Lots of scammers are trying to game the system in many ways. Don't plan on making a living solely from AppStore revenues nor plan on Google being responsive.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use LogCat:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> It can be difficult in Android to figure out 'what went wrong'. Run the application in the debugger and look at the logcat window. I found it worthwhile to add a new perspective with just a maximized logcat window. If you like to have a colored LogCat output in a separate window try this tool: <a href="http://jsharkey.org/blog/2009/04/22/modifying-the-android-logcat-stream-for-full-color-debugging/">Colored LogCat</a></span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l1 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Explore the tools directory:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"> There a lot helpful tools in the sdk's tools directory, such as hierarchyviewer and layoutopt. Each is helpful and there is no shortcut to learning about each tool one at a time.</span></li>
</ol><div class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="color: #6c0000; font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Important Tips:</span></b></div><ol start="1" type="1"><li class="MsoNormal" style="line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Don't forget to free resources after use</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">.<br />
Lot of resources like Cursors are overlooked. Free them too.</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Don't Use magic Numbers.</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"><br />
values[0] is meaningless. The framework provides very useful accessors like </span><span style="font-family: "Times New Roman","serif"; font-size: 10pt;">values[SensorManager.DATA_X]</span><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"></span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l0 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">"Make use of <b>onPause()/onResume</b> to save or close what does not need to be opened the whole time."</span></li>
</ol><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: "Times New Roman","serif"; font-size: 10pt;">protected void onResume() {<br />
mSensorManager.registerListener(...);<br />
}<br />
protected void onStop() {<br />
mSensorManager.unregisterListener(...);<br />
super.onStop();<br />
}</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in left 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-indent: -.25in;"><span style="color: #660000; font-family: "Times New Roman","serif"; font-size: 10pt;">4.<span style="font: 7pt "Times New Roman";"> </span></span><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"><a href="http://www.youtube.com/watch?v=N6YdwzAvwOA" style="color: #660000;">Make your Android UI Fast and Efficient</a> from the Google I/O has a lot of useful UI Performance tips.</span><span style="font-family: "Times New Roman","serif"; font-size: 10pt;"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;"><a href="http://developer.android.com/guide/practices/design/performance.html" style="color: #660000;">Designing for Performance</a><span style="color: #660000;"> </span>covers:</span></b></div><ul type="disc"><li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Optimize Judiciously</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Avoid Creating Objects</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Performance Myths </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Prefer Static Over Virtual</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Avoid Internal Getters/Setters</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Static Final For Constants</span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Enhanced For Loop Syntax </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Avoid Enums Where You Only Need Ints </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Package Scope with Inner Classes </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Floating-Point Judiciously </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Know And Use The Libraries </span></li>
<li class="MsoNormal" style="line-height: normal; mso-list: l2 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt;">Use Native Methods Judiciously</span></li>
</ul><b style="mso-bidi-font-weight: normal;"><a href="http://developer.motorola.com/docstools/library/Best_Practices_for_User_Interfaces/">Best Practices for User Interfaces</a>:</b><br />
<div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>1 Read the UI guidelines</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>2 Understand and design for touch mode</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>3 But, support multiple interaction modes</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>4 Use notifications and the window shade</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>5 Support interaction between applications</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>6 Keep your UI fast and responsive</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>7 Use widgets and live folders</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>8 Handle screen orientation changes</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>9 Use images wisely</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>10 Use layouts that adapt to multiple devices</div><div style="margin-left: .5in; mso-list: l2 level1 lfo3; tab-stops: list .5in; text-indent: -.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span>And from SO:</div><div style="color: #20124d; margin-left: 0.5in; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span><a href="http://stackoverflow.com/questions/1002492/android-best-practice-for-responsive-user-interfaces">Android: Best practice for responsive user interfaces</a></div><div style="color: #20124d; margin-left: 0.5in; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: 7pt "Times New Roman";"> </span></span><a href="http://stackoverflow.com/questions/522312/best-practices-for-unit-testing-android-apps">Best practices for unit testing Android apps</a></div><div class="MsoNormal"><br />
</div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-84416952876991698772012-03-01T20:01:00.000+05:302012-03-01T20:01:26.710+05:30Using NDK to Call C code from Android Apps Part-2<div dir="ltr" style="text-align: left;" trbidi="on"><div class="message"><b>Updated for NDK 1.6</b><br />
<br />
While Android SDK is great for application development, every once in a while you may need access to native code. This code is usually done in C. While you were able to access native code via Java Native Interface (JNI) all along, the process was rather hard. You would've typically had to compile everything on your host computer for the target architecture, requiring you to have the entire toolchain on your development machine.<br />
<br />
Android NDK (Native Development Kit) simplifies working with native code. It includes the entire toolchain needed to build for your target platform (ARM). It is designed to help you create that shared library.<br />
<br />
<br />
<br />
<br />
Note that native code accessible via JNI still runs inside the Dalvik VM, and as such is subject to the same life-cycle rules that any Android application lives by. The advantage of writing parts of your app code in native language is presumably speed in certain cases.<br />
<br />
<b>Note:</b> I'm using <code class="inline"><NDKHOME></code> to refer to the root directory in which you installed your NDK. For me that's <code class="inline">/Users/marko/WorkArea/android-ndk-1.6_r1</code>. I'm assuming all other directories and files are relative to your Eclipse project root, in my case <code class="inline">/Users/marko/Workspace/Android/NDKDemo</code>.<br />
<br />
<b>Overview</b><br />
<br />
<img alt="" src="http://marakana.com/static/tutorials/NDK.png" /><br />
<br />
<br />
We are roughly going to do this:<br />
<br />
1. Create the Java class representing the native code<br />
2. Create the native code header file<br />
3. Implement the native code by writing your C code<br />
4. Compile everything and build you Shared Library<br />
5. Use your native code inside Android activity<br />
<br />
<br />
<b>Create Native Library</b><br />
<br />
This is just a Java file that lives in standard <code class="inline">src</code> directory in your Eclipse project. It serves as the glue to the native code that we'll write later.<br />
<br />
<b>/src/com.marakana/NativeLib.java</b><br />
<div class="code">Code:<br />
<br />
<pre>package com.marakana;
public class NativeLib {
<b>static {
System.loadLibrary("ndk_demo");
}</b>
/**
* Adds two integers, returning their sum
*/
<b>public native int add( int v1, int v2 )</b>;
/**
* Returns Hello World string
*/
<b>public native String hello()</b>;
}</pre></div><br />
<br />
<br />
<b>Create C Header File</b><br />
In your project bin directory (in my case, <code class="inline"><EclipseWorkspace>/NDKDemo/bin</code>), run javah tool to create the JNI header file.<br />
<br />
Next, create a jni directory in your project directory (in my case, <code class="inline"><EclipseWorkspace>/NDKDemo/jni</code>).<br />
<br />
Next, copy the JNI header from <code class="inline"><EclipseWorkspace>/NDKDemo/bin</code> to <code class="inline"><EclipseWorkspace>/NDKDemo/jni</code><br />
<br />
Here's my command line:<br />
<br />
<div class="code">Code:<br />
<br />
<pre>NDKDemo/bin$ javah -jni com.marakana.NativeLib
NDKDemo/bin$ mv com_marakana_NativeLib.h ../jni/</pre></div><br />
<br />
<b>Write the C Code</b><br />
<br />
In your <code class="inline"><EclipseWorkspace>/NDKDemo/jni/</code> folder, create <code class="inline">ndk_demo.c</code> file. This is where we'll implement the native code. To start, copy the function signatures from the header file, and provide the implementation for those functions. In this example, the header file looks like this:<br />
<br />
<b><EclipseWorkspace>/NDKDemo/jni/com_marakana_NativeLib.h</b><br />
<div class="code">Code:<br />
<br />
<pre>/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_marakana_NativeLib */
#ifndef _Included_com_marakana_NativeLib
#define _Included_com_marakana_NativeLib
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_marakana_NativeLib
* Method: add
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_com_marakana_NativeLib_add
(JNIEnv *, jobject, jint, jint);
/*
* Class: com_marakana_NativeLib
* Method: hello
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_marakana_NativeLib_hello
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif</pre></div><br />
<br />
And the corresponding implementation looks like this:<br />
<br />
<b><EclipseWorkspace>/NDKDemo/jni/ndk_demo.c</b><br />
<div class="code">Code:<br />
<br />
<pre>#include "com_marakana_NativeLib.h"
JNIEXPORT jstring JNICALL Java_com_marakana_NativeLib_hello
(JNIEnv * <b>env</b>, jobject <b>obj</b>) {
<b>return (*env)->NewStringUTF(env, "Hello World!");</b>
}
JNIEXPORT jint JNICALL Java_com_marakana_NativeLib_add
(JNIEnv * <b>env</b>, jobject <b>obj</b>, jint <b>value1</b>, jint <b>value2</b>) {
<b>return (value1 + value2);</b>
}</pre></div><br />
<br />
<br />
<b>Build The Library</b><br />
<br />
To build the library, first we need to create a makefile for how to compile the C code:<br />
<br />
<b><EclipseWorkspace>/NDKDemo/jni/Android.mk</b><br />
<div class="code">Code:<br />
<br />
<pre>LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndk_demo
LOCAL_SRC_FILES := ndk_demo.c
include $(BUILD_SHARED_LIBRARY)</pre></div><br />
<br />
Next, we need to tell NDK how to build the shared library and put it in the correct place inside the Eclipse project. To do this, create a folder <code class="inline"><NDKHOME>/apps/ndk_demo/</code> and inside this folder create the Application file:<br />
<br />
<b><NDKHOME>/apps/ndk_demo/Application</b><br />
<div class="code">Code:<br />
<br />
<pre>APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := ndk_demo</pre></div><br />
<br />
Next, create a symbolic link <code class="inline"><NDKHOME>/apps/ndk_demo/project</code> to your Eclipse project:<br />
<br />
<code class="inline">ln -s ~/Workspace/Android/NDKDemo <NDKHOME>/apps/ndk_demo/project</code><br />
<br />
If you are on Windows, or another OS that doesn't support symbolic links, you may have to copy entire Eclipse project into <code class="inline"><NDKHOME>/apps/ndk_demo/project</code> directory, then copy back to Eclipse. I'm running all this on Mac OS X 10.6 and I assume Linux-type shell.<br />
<br />
You can now to to your <NDKHOME> and run <code class="inline">make APP=ndk_demo</code><br />
<br />
The output should look lie this:<br />
<br />
<div class="code">Code:<br />
<br />
<pre>android-ndk-1.5_r1$ make APP=ndk_demo
Android NDK: Building for application 'ndk_demo'
Compile thumb : ndk_demo <= sources/ndk_demo/ndk_demo.c
SharedLibrary : libndk_demo.so
Install : libndk_demo.so => apps/ndk_demo/project/libs/armeabi</pre></div><br />
<br />
You can now refresh your Eclipse project and you should <code class="inline">/lib/</code> directory containing your <code class="inline">libndk_demo.so</code> file.<br />
<br />
<b>Calling Native Code from Java</b><br />
<br />
So now that we have the native C library implemented, compiled, and placed in the right place, let's see how we can call it from our Activity. It's actually rather simple - you just have to instantiate the instance of your <code class="inline">NativeLib</code> class and from there on, it's just a regular Java object.<br />
<br />
<b>/src/com.marakana/NDKDemo.java</b><br />
<div class="code">Code:<br />
<br />
<pre>package com.marakana;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class NDKDemo extends Activity {
<b>NativeLib nativeLib;</b>
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
<b>nativeLib = new NativeLib();</b>
String helloText = <b>nativeLib.hello()</b>;
// Update the UI
TextView outText = (TextView) findViewById(R.id.textOut);
outText.setText(helloText);
// Setup the UI
Button buttonCalc = (Button) findViewById(R.id.buttonCalc);
buttonCalc.setOnClickListener(new OnClickListener() {
TextView result = (TextView) findViewById(R.id.result);
EditText value1 = (EditText) findViewById(R.id.value1);
EditText value2 = (EditText) findViewById(R.id.value2);
public void onClick(View v) {
int v1, v2, res = -1;
v1 = Integer.parseInt(value1.getText().toString());
v2 = Integer.parseInt(value2.getText().toString());
<b>res = nativeLib.add(v1, v2);</b>
result.setText(new Integer(res).toString());
}
});
}
}</pre></div><br />
<br />
<br />
The UI for this example is not that significant, but I'm going to include it here for the sake of completeness. <br />
<br />
<b>/res/layout/main.xml</b><br />
<div class="code">Code:<br />
<br />
<pre><?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:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="NDK Demo"
android:textSize="22sp" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textOut"
android:text="output"></TextView>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/value1"
android:hint="Value 1"></EditText>
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="+"
android:textSize="36sp"></TextView>
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/value2"
android:hint="Value 2"></EditText>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/buttonCalc"
android:text="="></Button>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="result"
android:textSize="36sp" android:id="@+id/result"></TextView>
</LinearLayout></pre></div><br />
<br />
<br />
<b>Output</b><br />
<img alt="" src="/static/tutorials/NDKDemo.png" /><br />
<br />
<b>Source Code</b><br />
<a href="http://marakana.com/static/tutorials/NDKDemo.zip" rel="nofollow">http://marakana.com/static/tutorials/NDKDemo.zip</a><br />
<a href="http://marakana.com/static/tutorials/NDKHOME.zip" rel="nofollow">http://marakana.com/static/tutorials/NDKHOME.zip</a><br />
<br />
</div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-23660723930537495092012-03-01T19:53:00.002+05:302012-03-01T20:02:33.385+05:30Using NDK to Call C code from Android Apps Part-1<div dir="ltr" style="text-align: left;" trbidi="on">The Android NDK is a set of tools that allows Android application developers to embed native machine code compiled from C and/or C++ source files into their application packages.<br />
While you were able to access native code via Java Native Interface (JNI) all along, You would’ve typically had to compile everything on your host computer for the target architecture, requiring you to have the entire toolchain on your development machine.<br />
Android NDK (Native Development Kit) simplifies working with native code. It includes the entire toolchain needed to build for your target platform (ARM). It is designed to help you to create that <i>shared library.</i> <br />
<b>To do’s:</b><br />
1. Create the Java class that represents the native code<br />
2. Create header file for the native code.<br />
3. Implement the native code by writing your C code<br />
4. Compile everything and build you Shared Library<br />
5. Use your native code inside Android activity<br />
<b>1. Create Native Library</b><br />
Create a Native Library in src directorary in your Eclipse project.<br />
/src/com.mobisoftinfotech/NativeLib.java<br />
<b>2. Create C Header File</b><br />
In your project bin directory (in my case, /<workspace>/NDKDemo/bin), run javah tool to create the JNI header file.<br />
NDKDemo/bin$ javah -jni com.mobisoftinfotech.NativeLib<br />
Next, create a jni directory in your project directory ( in my case , <EclipseWorkspace>/NDKDemo/jni).<br />
Next, copy the JNI header from <EclipseWorkspace>/NDKDemo/bin to <EclipseWorkspace>/NDKDemo/jni<br />
<a href="http://www.mobisoftinfotech.com/blog/wp-content/uploads/2010/07/Main-Screen2.png"><img alt="" class="aligncenter size-medium wp-image-1252" height="240" src="http://www.mobisoftinfotech.com/blog/wp-content/uploads/2010/07/Main-Screen2-300x240.png" width="300" /></a><br />
<b>3. Write the C Code</b><br />
In your <EclipseWorkspace>/NDKDemo/jni/ folder, create ndkMathdemo.c file. This is where we’ll implement the native code. To start, copy the function signatures from the header file, and provide the implementation for those functions. In this example, the header file looks like this:<br />
<EclipseWorkspace>/NDKDemo/jni/com_mobisoftinfotech_NativeLib.h<br />
<b>4. Build The Library</b><br />
To build the library, first we need to create a makefile for how to compile the C code:<br />
<EclipseWorkspace>/NDKDemo/jni/Android.mk<br />
Next, we need to tell NDK how to build the shared library and put it in the correct place inside the Eclipse project. To do this, create a folder <NDKHOME>/apps/ndkMathsdemo/ and inside this folder create the Application file:<br />
<NDKHOME>/apps/ndkMathsdemo/Application<br />
You can now to to your <NDKHOME> and run make APP=ndkMathsdemo<br />
<b>The output should look like this on terminal:-</b><br />
android-ndk-r4$ make APP=ndkMathsdemo<br />
Android NDK: Building for application ‘ndkMathsdemo’<br />
Compile thumb : ndkMathsdemo <= sources/ndkMathdemo/ndkMathdemo.c<br />
SharedLibrary : libndkMathdemo.so<br />
Install : libndkMathsdemo.so => apps/ndk_demo/project/libs/armeabi<br />
You can now refresh your Eclipse project and you should /lib/ directory containing your libndkMathsdemo.sofile.<br />
<b>5. Calling Native Code from Java</b><br />
So now that we have the native C library implemented, compiled, and placed in the right place, let’s see how we can call it from our Activity. It’s actually rather simple – you just have to instantiate the instance of your NativeLib class and from there on, it’s just a regular Java object.<br />
<a href="http://www.mobisoftinfotech.com/blog/wp-content/uploads/2010/07/output1.png"><img alt="" class="aligncenter size-medium wp-image-1254" height="300" src="http://www.mobisoftinfotech.com/blog/wp-content/uploads/2010/07/output1-200x300.png" width="200" /></a><br />
<b>Source Code: </b><a href="http://www.mobisoftinfotech.com/blog/wp-content/uploads/2010/07/NDKDemo.tar1.gz">NDKDemo.tar</a></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-45451144625755052222012-01-30T14:21:00.000+05:302012-01-30T14:21:37.195+05:30How to Get Your Eclipse-Integrated NDK On Here are the few steps<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<br />
Here's how to set up a super speedy NDK development environment.<br />
First of all, Eclipse can do way more than just Java. Java is what it's great at and what it was designed for but the architecture makes it so that it can handle any language effectively, including C. There is a component called CDT that allows for C/C++ Development in Eclipse. I'm getting ahead of myself, though. Here's what you need:<br />
<br />
<br />
<b><a href="http://api.viglink.com/api/click?format=go&key=688b5520193568993770aadc5e0e5ec8&loc=http%3A%2F%2Fandroid-vogue.blogspot.com%2Fsearch%2Flabel%2FAndroid_NDK&v=1&libid=1327913220507&out=http%3A%2F%2Fdeveloper.android.com%2Fsdk%2Fndk%2F1.6_r1%2Findex.html&ref=http%3A%2F%2Fandroid-vogue.blogspot.com%2F2011%2F07%2Fsimple-android-animation-application.html&title=Android%20Developer%3A%20Android_NDK&txt=Android%20NDK%20(Native%20Development%20Kit)&jsonp=vglnk_jsonp_13279134527173" target="_blank">Android NDK (Native Development Kit)</a></b><br />
<br />
<b><a href="http://api.viglink.com/api/click?format=go&key=688b5520193568993770aadc5e0e5ec8&loc=http%3A%2F%2Fandroid-vogue.blogspot.com%2Fsearch%2Flabel%2FAndroid_NDK&v=1&libid=1327913220507&out=http%3A%2F%2Fwww.eclipse.org%2Fcdt%2F&ref=http%3A%2F%2Fandroid-vogue.blogspot.com%2F2011%2F07%2Fsimple-android-animation-application.html&title=Android%20Developer%3A%20Android_NDK&txt=Eclipse%20CDT%20(C%20Development%20Tooling)&jsonp=vglnk_jsonp_13279134825664" target="_blank">Eclipse CDT (C Development Tooling)</a></b><br />
<br />
<br />
If you're in Windows, you'll need Cygwin with the develop packages installed (Especially GCC and Make)<br />
<br />
<br />
Here's what you need to do:<br />
Install all 3 of those things. I like to install my NDK to c:\Android_NDK. I'll refer to that dir for the rest of this article.<br />
Get acquainted with the NDK. You need to configure each project as an "app" in the c:\Android_NDK\apps dir. Just take a look at the examples. They work and are thorough.<br />
How to test your NDK:<br />
Run cygwin<br />
cd /cygdrive/c/Android_NDK<br />
make APP=hello-jni<br />
<br />
<br />
It should roll up without errors. If you are lacking GCC or Make or any other develop packages, you will want to run your Cygwin setup again and check to make sure that all of the development packages are installed. If you have strange errors, I suggest reporting them in the NDK user's group.<br />
Once your NDK is running, you can add an app for your project and set up the basic native framework for your project. Please refer to the examples for this part. You will need a specific build file that tells the compiler what sources to compile. JNI code is usually located in your Android project's jni folder. A file called Android.mk will need to be in there which instructs the compiler on what to compile.<br />
After you get the basic configuration done, you will want to start writing some C. NDK uses Java's standard JNI bindings to work. All of the existing documentation on JNI should apply from this point forward. What to code is beyond the scope of this article.<br />
<br />
<br />
Now for the good part :<br />
If you've done any NDK work, you're probably used to using a text editor or vim or some other editor to edit your C/CPP then running make APP=myapp every time to build, then clicking refresh on your project in Eclipse and then hoping that the shared object library file that gets deployed is current. What a pain in the ass! There's a much, much better way.<br />
Now that you have CDT installed, you can edit all of your C/C++ right from Eclipse. If you right click on a C/CPP source file, just pick Open With--C/C++ Editor and it will use the CDT editor. Much nicer! It won't be able to figure out what the code is doing because it's not compiling it, but it will make editing nice and all in one spot.<br />
Building is a snap as well. Ever used builders in Eclipse? They are configurable triggers that will execute what you configure and refresh resources for you. Make sure you know if you're on the old r3 NDK (upgrade if you are - you should be on r4) and if so, I put different instructions in this list for the different versions. Here's how I set mine up:<br />
<br />
<br />
<br />
Right click on your project, pick properties.<br />
Select "builders" from the left-hand list.<br />
Click "New..." on the right side.<br />
Select "Program" as the configuration type.<br />
I name mine "Native Builder"<br />
Location - c:\cygwin\bin\bash.exe<br />
Working Directory - c:\cygwin\bin<br />
Arguments -<br />
(for NDK r3):<br />
--login -c "cd /cygdrive/c/Android_NDK && make APP=myapp"<br />
(for NDK r4):<br />
--login -c "cd /cygdrive/c/<myapp_project_dir> && /cygdrive/c/Android_NDK/ndk-build"<br />
Make sure you have the two hyphens before login and the quotes after the hyphen-c<br />
Now go to the refresh tab<br />
Check "Refresh resources upon completion"<br />
Select "Specific resources"<br />
Click on the "Specify resources" button and select your project's lib directory.<br />
Check "Recursively include sub-folders"<br />
Now go to the build options tab<br />
Check "Allocate Console"<br />
Check "Launch in background"<br />
Check "Run the builder After a Clean"<br />
Check "Run the builder During manual builds"<br />
Check "Run the builder During auto builds"<br />
Check "Specify working set of relevant resources"<br />
Click on "Specify Resources"<br />
Select your project's JNI directory and all files within.<br />
Now click OK on the bottom.<br />
The assumption here is that cygwin is installed to c:\cygwin, NDK is in c:\Android_NDK and your project is called "myapp". Change where appropriate.<br />
What did you just do?! You made it so that any time you edit any files within your JNI directory and you save them, Eclipse will run the NDK Builder for you via CygwinADT to compile a new APK for you and YOU ARE GOOD TO GO!<br />
</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-7447209510299044182012-01-30T14:18:00.003+05:302012-01-30T14:23:51.810+05:30Android NDK Introduction<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="background-color: white; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">The Android NDK is a companion tool to the Android SDK that lets you build performance-critical portions of your apps in native code. It provides headers and libraries that allow you to build activities, handle user input, use hardware sensors, access application resources, and more, when programming in C or C++. If you write native code, your applications are still packaged into an .apk file and they still run inside of a virtual machine on the device. The fundamental Android application model does not change.</div><div style="background-color: white; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"><span style="line-height: 1.3em;">The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications.</span></div><div style="background-color: white; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"></div><div style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Android applications run in the Dalvik virtual machine. The NDK allows you to implement parts of your applications using native-code languages such as C and C++. This can provide benefits to certain classes of applications, in the form of reuse of existing code and in some cases increased speed.</div><div style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">The NDK provides:</div><ul style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2em; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;">A set of tools and build files used to generate native code libraries from C and C++ sources</li>
<li style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;">A way to embed the corresponding native libraries into an application package file (<code style="color: #007000; line-height: 1em;">.apk</code>) that can be deployed on Android devices</li>
<li style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;">A set of native system headers and libraries that will be supported in all future versions of the Android platform, starting from Android 1.5. Applications that use native activities must be run on Android 2.3 or later.</li>
<li style="border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Documentation, samples, and tutorials</li>
</ul><br />
<br />
Sooner or future in your Android game development attempt you may find the need to have some code that runs faster. It turns out that Android code written in C runs 10-100 times as fast as its Java counterpart. I can verify this, as I've already moved a few major components in my newest 3D game engine into native land. That's quite a boost but let's face it - C is a pain in the ass and while Eclipse is great for Java, it's not for C, right?<br />
Wrong.<br />
<br />
<a href="http://android-solution-sample.blogspot.com/2012/01/how-to-get-your-eclipse-integrated-ndk.html" target="_blank">Continue</a><br />
<br />
<div style="background-color: white; border-bottom-width: 0px; border-color: initial; border-image: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"><span style="color: #333333; font-family: arial, sans-serif; font-size: x-small;"><span style="line-height: 16px;"><br />
</span></span></div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com1tag:blogger.com,1999:blog-5778662197868112639.post-85906492880162957172012-01-07T15:56:00.001+05:302012-01-07T15:56:55.406+05:30Android interview questions<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What is an action?</b><br />
The Intent Sender desires something or doing some task<br />
<br />
<b>What is activity?</b><br />
A single screen in an application, with supporting Java code.<br />
<br />
<b>What is intent in Android?</b><br />
A class (Intent) will describes what a caller desires to do. The caller will send this intent to Android's intent resolver, which finds the most suitable <span class="IL_AD" id="IL_AD2" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">activity for</span> the intent. E.g. opening a <span class="IL_AD" id="IL_AD4" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">PDF document</span> is an intent, and the <span class="IL_AD" id="IL_AD3" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Adobe Reader</span> apps will be the perfect activity for that intent(class).<br />
<br />
<b>What is a Sticky Intent?</b><br />
sendStickyBroadcast() performs a sendBroadcast (Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver (BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent).</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery <span class="IL_AD" id="IL_AD7" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">without</span> necessarily registering for all future state changes in the battery.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Is there anyway to <span class="IL_AD" id="IL_AD5" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">determine</span> if an Intent passed into a BroadcastReceiver's onReceive is the result of a sticky Boradcast Intent, or if it was just sent?<br />
<br />
<b>Example for sticky broadcast</b><br />
When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery withoutnecessarily registering for all future state changes in the battery.<br />
<br />
<b>How the nine-patch Image different from a regular bitmap? or Different between nine-patch Image vs regular Bitmap Image</b><br />
It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.<br />
<br />
<b>What Programming languages does Android support <span class="IL_AD" id="IL_AD11" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">for application</span>development?</b><br />
Android applications supports using Java Programming Language. which is coded in Java and complied using <span class="IL_AD" id="IL_AD9" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Android SDK</span>.<br />
<br />
<b>What is a resource?</b><br />
A user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.<br />
<br />
<b>How will you record <span class="IL_AD" id="IL_AD6" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">a phone call</span> in Android? or How to handle on Audio Stream for a call in Android?</b><br />
Permissions.PROCESS_OUTGOING_CALLS: Will Allows an application to monitor, modify, or abort outgoing calls. So through that we can monitor the Phone calls.<br />
<br />
<b>What's the difference between class, file and activity in android?</b><br />
Class - The <span class="IL_AD" id="IL_AD8" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Class file</span> is complied from .java file. Android will use this .class fileto produce the executable apk.<br />
File - It is a block of resources, srbitrary information. It can be any file type.<br />
Activity - An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.<br />
<br />
<b>Does Android support the Bluetooth serial port profile?</b><br />
A. Yes.<br />
<b>Can an application be started on powerup?</b><br />
A. Yes.<br />
<br />
<b>What is APK format.</b><br />
The APK file is compressed AndroidManifest.xml file with extension .apk, Which have application code (.dex files), resource files, and other files which is compressed into single .apk file.<br />
<br />
<b>How to Translate in android</b><br />
The <span class="IL_AD" id="IL_AD12" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Google translator</span> translates the data of one language into <span class="IL_AD" id="IL_AD10" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">another language</span> by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens.<br />
<br />
<b>What is an action?</b><br />
A description of something that an Intent sender desires.<br />
<br />
<b>What are the advantages of Android?</b><br />
The following are the advantages of Android:<br />
<br />
* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like Orange and AT&T will be broken by Google Android.<br />
* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized<br />
* Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What is the TTL (Time to Live)? Why is it required?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">TTL is a value in data packet of Internet Protocol. It communicates to the network router whether or not the packet should be in the network for too long or discarded. Usually, data packets might not be transmitted to their intended destination within a stipulated period of time. The TTL value is set by a system default value which is an 8-bit binary digit field in the header of the packet. The purpose of TTL is, it would specify certain time limit in seconds, for transmitting the packet header. When the time is exhausted, the packet would be discarded. Each router receives the subtracts count, when the packet is discarded, and when it becomes zero, the router detects the discarded packets and sends a message, Internet Control Message Protocol message back to the originating host.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>How is nine-patch image different from a regular bitmap?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>Explain IP datagram, Fragmentation and MTU ?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">IP datagram can be used to describe a portion of IP data. Each IP datagram has set of fields arranged in an order. The order is specific which helps to decode and read the stream easily. IP datagram has fields like Version, header length, Type of service, Total length, checksum, flag, protocol, Time to live, Identification, source and destination ip address, padding, options and payload.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">MTU:- Maximum Transmission Unit is the size of the largest packet that a communication protocol can pass. The size can be fixed by some standard or decided at the time of connection</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Fragmentation is a process of breaking the IP packets into smaller pieces. Fragmentation is needed when the datagram is larger than the MTU. Each fragment becomes a datagram in itself and transmitted independently from source. When received by destination they are reassembled.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>Explain about the exceptions of Android?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">The following are the exceptions that are supported by Android<br />
* InflateException : When an error conditions are occurred, this exception is thrown<br />
* Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown<br />
* SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS<br />
* WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>Describe Android Application Architecture?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Android Application Architecture has the following components:</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Services ? like Network Operation</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Intent - To perform inter-communication between activities or services</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Resource Externalization - such as strings and graphics</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* <span class="IL_AD" id="IL_AD1" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: #009900; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Notification</span> signaling users - light, sound, icon, notification, dialog etc.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Content Providers - They share data between applications</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What are the advantages of Android?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">The following are the advantages of Android:</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>How to select more than one option from list in android xml file? Give an example.</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Specify android id, layout height and width as depicted in the following example.<br />
<br />
<listview id="@+id/ListView01" layout_height="wrap_content" layout_width="fill_parent"></listview></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>Explain about the exceptions of Android?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">The following are the exceptions that are supported by Android</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* InflateException : When an error conditions are occurred, this exception is thrown</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">* WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What are the features of Android?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">*Components can be reused and replaced by the application framework.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">*Optimized DVM for mobile devices</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">*SQLite enables to store the data in a structured manner.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">*Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">*The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What are the differences between a domain <span id="IL_AD7" style="font-weight: normal !important;"><span class="ilad">and a</span></span> workgroup?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">In a domain, one or more computer can be a server to manage the network. On the other hand in a workgroup all computers are peers having no control on each other. In a domain, user doesn?t need an account to logon on a specific computer if an account is available on the domain. In a work group user needs to have an account for every computer.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">In a domain, Computers can be on different local networks. In a work group all computers needs to be a part of the same local network.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What is android?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Android is a stack of <span class="ilad"><span id="IL_AD3">software for mobile</span></span> devices which has Operating System,<span class="ilad"><span id="IL_AD1">middleware</span></span> and some key applications. The <span class="ilad"><span id="IL_AD4">application</span></span> executes within its own process and its own instance of Dalvik <span class="ilad"><span id="IL_AD7">Virtual Machine</span></span>. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later <span class="ilad"><span id="IL_AD5">transforms</span></span> into .dex format files.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What is needed to make a <span id="IL_AD2" style="font-weight: normal !important;"><span class="ilad">multiple choice</span></span> list with a custom view for each row?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Multiple choice list can be viewed by making the <span class="ilad"><span id="IL_AD4">CheckBox</span></span> android:id value be “@android:id /text1". That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>What are the dialog boxes that are supported in android? Explain.</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Android supports 4 dialog boxes:<br />
<br />
AlertDialog : An alert <span class="ilad"><span id="IL_AD7">dialog box</span></span> supports 0 to 3 buttons and a list of selectable elements, including check boxes and <span class="ilad"><span id="IL_AD6" style="font-weight: bold !important;">radio buttons</span></span>. Among the other dialog boxes, the most suggested dialog box is the alert dialog box.<br />
<br />
ProgressDialog: This dialog box displays a progress wheel or a progress <span class="ilad"><span id="IL_AD8">bar</span></span>. It is an extension of AlertDialog and supports adding buttons.<br />
<br />
DatePickerDialog: This dialog box is used for selecting a date by the user.<br />
<br />
TimePickerDialog: This dialog box is used for selecting <span class="ilad"><span id="IL_AD3">time by</span></span> the user.</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b>How to Remove <span id="IL_AD3" style="font-weight: normal !important;"><span class="ilad">Desktop icons</span></span> and Widgets?</b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;">Press and Hold the icon or widget. The phone will vibrate and on the bottom of the phone you will see an option to remove. While still holding the icon or widget <span class="ilad"><span id="IL_AD9">drag</span></span> it to the remove <span class="ilad"><span id="IL_AD10">button</span></span>. Once remove <span class="ilad"><span id="IL_AD5">turns</span></span> red drop the item and it is gone</div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-bottom: 12pt; text-align: -webkit-auto;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Common Tricky questions</span></b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;"></span></div><ul style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px; text-align: -webkit-auto;" type="disc"><li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Remember that the GUI layer doesn't request data directly from the web; data is always loaded from a local database.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The service layer periodically updates the local database.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is the risk in blocking the Main thread when performing a lengthy operation such as web access or heavy computation? Application_Not_Responding exception will be thrown which will crash and restart the application.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Why is List View not recommended to have active components? Clicking on the active text box will pop up the software keyboard but this will resize the list, removing focus from the clicked element.</span></li>
</ul><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"><b><span style="font-size: 12pt; line-height: 18px;">For senior employees</span></b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-bottom: 12pt; text-align: -webkit-auto;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Beyond a certain level of experience, the job interview questions cease to be "difference between abstract class and interface", and focus more on testing your technical acumen, collaboration and communication skills. A list of such questions, typically asked during interviews for senior positions is given below:</span></div><ul style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px; text-align: -webkit-auto;" type="disc"><li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Explain the life cycle of an application development process you worked on previously.<br />
<i>What the interviewer looks for is communication of requirements, planning, modeling, construction and deployment on the back end.</i></span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Here's a hypothetical project. Explain how you would go about it.<br />
<i>They want to know how you would break your work down into tasks and how many weeks for each task. I'm really looking to find out about planning methods, their skill set and how quickly they can execute.</i></span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you respond to requirement changes in the middle of a cycle?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What type of methodology have you used in the past? What are its drawbacks?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What are different techniques for prototyping an application?<br />
Similar question: Do you feel there is value in wireframing an application? Why?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you manage conflicts in Web applications when there are different people managing data?</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Tell me something you learned from a team member in the last year.</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What software testing procedures have you used to perform a QA?</span></li>
</ul><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; text-align: -webkit-auto;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Once the coding skills verified. Sample I</span></b></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The Activity life cycle is must. Ask about the different phases of Activity Life cycle. For example: when and how the activity comes to foreground?</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Check the knowledge on AndroidManifest file, For example: Why do we need this file, What is the role of this file in Android app development.</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Different Kinds of Intents</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about different Kinds of context</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about different Storage Methods in android</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Kinds of Log debugger and Debugger Configuration</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to debug the application on real device.</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How do you ensure that the app design will be consistent across the different screen resolutions</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Thread concepts also plus points as we deal with the treads more.</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Can you able to build custom views and how?</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to create flexible layouts, For example to place English, Chinese fonts.</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is localization and how to achieve?</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What are 9-patch images</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to avoid ANR status</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to do Memory management</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Ask about IPC</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">What is onCreate(<b>Bundle savedInstanceState</b>), Have you used savedInstanceState when and why?</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; margin-left: 1in; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: Symbol; font-size: 10pt;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">To check how updated the person is just ask about what are Fragments in an Activity</span></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; text-align: -webkit-auto;"></div><div class="MsoNormal" style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; text-align: -webkit-auto;"><b><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">If this is an Android specific job, just ask the obvious stuff. Sample II</span></b></div><ul style="background-color: #fff9ee; color: #222222; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 15px; line-height: 21px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px; text-align: -webkit-auto;" type="disc"><li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Application lifecycle</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">When to use a service</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to use a broadcast receiver and register it both in the manifest and in code</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Intent filters</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Stuff about what manifest attributes and tags mean</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">The types of flags to run an application</span></li>
<ul style="line-height: 1.4; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;" type="circle"><li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">FLAG_ACTIVITY_NEW_TASK</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">FLAG_ACTIVITY_CLEAR_TOP</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">etc</span></li>
</ul><li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to do data intensive calculations using threads</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Passing large objects (that can't be passed via intents and shouldn't be serialized) via a service</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">Binding to a service and the service lifecycle</span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.25em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: 'Times New Roman', serif; font-size: 12pt;">How to persist data (both savedInstanceState and more permanent ways)</span></li>
</ul></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-26652215524430650552011-12-20T15:09:00.001+05:302011-12-20T15:11:13.477+05:30Root the Amazon Kindle Fire<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<h2>Things You Need</h2><ul><li>A PC running Windows Vista or Windows 7</li>
<li>The Android SDK which has to be installed in your PC (click <a href="http://www.androidauthority.com/how-to-install-android-sdk-software-development-kit-21137/" target="_blank">here</a> for install details)</li>
<li>SuperOneClick v 2.2 (get it <a href="ftp://shortfuse.org/SuperOneClick/Packages/SuperOneClickv2.2-ShortFuse.zip" target="_blank">here</a>) — This is the software you will use to root the device.</li>
<li>USB cable for connecting your tablet to your PC</li>
<li>Amazon Kindle Fire</li>
</ul><h2>Step-by-step Procedure</h2><span style="font-weight: bold;">Step 1: </span>Install the Android SDK into your PC. The details about how to install the software development kit will not be discussed here because it’s a totally different subject on its own.<br />
<span style="font-weight: bold;">Step 2: </span>You now have to turn on “Allow Installation of Applications From Unknown Sources”. This can be done by tapping the Settings icon at the top right corner. Then, go to More->Device. You can turn on the setting from there.<br />
<img alt="" class="aligncenter size-full wp-image-36018" height="327" src="http://1.androidauthority.com/wp-content/uploads/2011/11/Allow_Applications.jpg" title="Allow_Applications" width="600" /> <br />
<div style="float: none; margin: 1px 0px; text-align: center;"> <script>
</script> <script>
</script> <ins style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; display: inline-table; height: 60px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; visibility: visible; width: 468px;"><ins id="aswift_0_anchor" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; display: block; height: 60px; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; visibility: visible; width: 468px;"><iframe allowtransparency="" frameborder="0" height="60" hspace="0" id="aswift_0" marginheight="0" marginwidth="0" name="aswift_0" scrolling="no" style="left: 0px; position: absolute; top: 0px;" vspace="0" width="468"></iframe></ins></ins></div><br />
<span style="font-weight: bold;">Step 3: </span>Connect the Kindle Fire to your PC using the micro USB to USB cable. If the connect screen comes up on the screen of the Kindle Fire, please do not tap on connect for this will enable USB connection.<br />
<img alt="" class="aligncenter size-full wp-image-36021" height="337" src="http://1.androidauthority.com/wp-content/uploads/2011/11/Kindle-Fire-USB-Mode.jpg" title="Kindle-Fire-USB-Mode" width="600" /><br />
<span style="font-weight: bold;">Step 4: </span>Modify <em>android_winusb.inf</em><br />
<ol><li>Go to the folder where the SDK is installed.</li>
<li>Open Extras->Google->USB Driver.</li>
<li>Right click on android_winusb.inf and choose “Open with” then select Notepad.<img alt="" class="aligncenter size-full wp-image-36024" height="320" src="http://1.androidauthority.com/wp-content/uploads/2011/11/USB_Driver_Location.jpg" title="USB_Driver_Location" width="600" /></li>
<li>Look for <code>[Google.NTx86]</code> and <code>[Google.NTamd64]</code> in the text that you just opened.<img alt="" class="aligncenter size-full wp-image-36023" height="482" src="http://1.androidauthority.com/wp-content/uploads/2011/11/USB_Driver_Code.jpg" title="USB_Driver_Code" width="600" /></li>
<li>Copy and paste the code below right beneath <code>[Google.NTx86]</code> and <code>[Google.NTamd64]</code> line (make sure to save the file after editing):</li>
</ol><blockquote> <code>;Kindle Fire<br />
%SingleAdbInterface% = USB_Install, USB\VID_1949&PID_0006<br />
%CompositeAdbInterface% = USB_Install, USB\VID_1949&PID_0006&MI_01</code></blockquote><span style="font-weight: bold;">Step 5: </span>Create <em>adb_usb.ini</em> and save it into the <code>.android</code> folder.<br />
<ol><li>Open Notepad.</li>
<li>Type <code>0x1949</code> and then save the file as <em>adb_usb.ini</em></li>
<li>Open Computer.</li>
<li>Go to Users.</li>
<li>Open the user login name folder you are using.</li>
<li>Copy and paste <em>adb_usb.ini</em> into the <code>.android</code> folder which you will see under the login name folder.<img alt="" class="aligncenter size-full wp-image-36017" height="331" src="http://1.androidauthority.com/wp-content/uploads/2011/11/adb_usb_location.jpg" title="adb_usb_location" width="600" /></li>
</ol><span style="font-weight: bold;">Step 6: </span>Update the USB driver for the Kindle Fire.<br />
<ol><li>Open Device Manager from the Control Panel window.<img alt="" class="aligncenter size-full wp-image-36019" height="505" src="http://1.androidauthority.com/wp-content/uploads/2011/11/device_manager.jpg" title="device_manager" width="593" /></li>
<li>Look for Kindle under Other Devices.</li>
<li>Right click Kindle and select “Update Driver Software”.</li>
<li>Select “Browse my computer for driver software”.</li>
<li>We now have to browse for the USB driver file we edited earlier, which should be located under Android SDK folder->Extras->Google.</li>
<li>After choosing the directory, just click Next and a prompt saying “Windows can’t verify the publisher of this driver software” will show up. Click “Install this driver software anyway”.</li>
</ol><span style="font-weight: bold;">Step 7: </span>Check if Android SDK will now recognize the Kindle Fire.<br />
<ol><li>Open up a command prompt window.</li>
<li>Go to the folder were the Android SDK is installed using the <code>cd</code> command.</li>
<li>From the Android SDK folder, access the <code>platform-tools</code> folder by still using the <code>cd</code> command.</li>
<li>Under the <code>platform-tools</code> folder, issue the <code>adb kill-server</code> command.</li>
<li>Next you have to issue the <code>adb devices</code> command. This will give you text similar to the one below. This will indicate that the SDK recognizes the Kindle Fire.</li>
</ol><blockquote> <code>* daemon not running. starting it now on port 5037 *<br />
* daemon started successfully *<br />
List of devices attached<br />
5246002600000001 device</code></blockquote><img alt="" class="aligncenter size-full wp-image-36016" height="315" src="http://1.androidauthority.com/wp-content/uploads/2011/11/adb_command_line.jpg" title="adb_command_line" width="600" /><br />
<span style="font-weight: bold;">Step 8: </span>The last part of the process is to root the device. Since we already downloaded the software from Shortfuse, we just have to extract it. After extracting the software, you just have to run it and it will automatically do its charm.<br />
<img alt="" class="aligncenter size-full wp-image-36022" height="324" src="http://1.androidauthority.com/wp-content/uploads/2011/11/superoneclick.jpg" title="superoneclick" width="600" /><br />
Now that rooting is done, your Kindle Fire will now be open for endless possibilities. More third-party apps can now be installed on the device<br />
</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com1tag:blogger.com,1999:blog-5778662197868112639.post-22725536862552305232011-12-08T19:00:00.001+05:302011-12-13T18:27:12.110+05:30Check Screen timeout / KeyGuard Lock<div dir="ltr" style="text-align: left;" trbidi="on"><span class="Apple-style-span" style="color: #4c1130;"><b>Check for the Screen timeout or not!</b></span><br />
<span class="Apple-style-span" style="color: #4c1130;"><b><br />
</b></span><br />
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);<br />
<br />
<br />
if(pm.isScreenOn())<br />
{<br />
Toast.makeText(this,"Screen is not locked", 20).show();<br />
}else<br />
Toast.makeText(this,"Screen is time out", 20).show();<br />
<span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-9161537984444304332011-12-07T11:51:00.000+05:302011-12-07T11:51:02.075+05:30Activity Launch Modes<div dir="ltr" style="text-align: left;" trbidi="on"><span></span> <br />
<div class="menu section" id="menu"><div class="widget PageList" id="PageList1"> <div class="widget-content"> <span class="widget-item-control"> </span> </div></div></div><div id="content-wrapper"> <div id="main-wrapper"> <div class="main section" id="main"><div class="widget Blog" id="Blog1"> <div class="blog-posts hfeed"> <div class="date-outer"> <div class="date-posts"> <div class="post-outer"> <div class="post hentry"> <a href="" name="6094511718289149616"></a> <h3 class="post-title entry-title"> <a href="http://androidisland.blogspot.com/2010/12/activity-launch-modes-simple.html">Activity Launch Modes - A simple explanation in a table.</a> </h3><div class="post-header-line-1"> <h2 class="date-header"><span></span></h2><span class="post-author vcard"><br />
</span><span class="post-labels"><a href="http://androidisland.blogspot.com/search/label/Android" rel="tag"></a> </span> </div><div class="post-body entry-content"> An Android Activity launch mode dictates to which Task an Activity is created and how it is instantiated. Its a tiny bit confusing to figure out exactly what launch mode you need from the <a href="http://developer.android.com/guide/topics/fundamentals.html#lmodes">official documentation</a> so I've created a small table to help.<br />
<br />
First of all here is a brief definition of some of the terms:<br />
<br />
<li><b>Task</b> - A "stack of Activities" in your application. If an Activity is sent to the background (by pressing the HOME key whilst viewing it, for example) then the whole Task (and all the Activities inside it) will be sent back as well. If the user then clicks on your application, the task (and the order of its activities) come forward.</li><br />
<br />
<br />
<li><b>Root of a task</b> - The first Activity in a Task. There is always one of these in a Task.</li><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-XuPgwCfew5SDpl_7fDEOHCC8ZbbbSQIRpI2PF53Pf9thOBCIKBHepfHg6Pzv2JGVa1TfFUxZQOJZJHqdvJ1S5MYEjPN7zh4-PkCvROjR0FAsJ-XqmtpyIB7PImInpQArT9Wxp_rf03g/s1600/activitymodes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="81" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-XuPgwCfew5SDpl_7fDEOHCC8ZbbbSQIRpI2PF53Pf9thOBCIKBHepfHg6Pzv2JGVa1TfFUxZQOJZJHqdvJ1S5MYEjPN7zh4-PkCvROjR0FAsJ-XqmtpyIB7PImInpQArT9Wxp_rf03g/s320/activitymodes.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_JHMkMKLWbtQ/TRjJhg0y6TI/AAAAAAAAH3U/KJRovtfL2Ds/s1600/Untitled-1.png"><br />
</a></div></div></div></div></div></div></div></div></div></div></div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-61863994379401338792011-12-07T10:44:00.000+05:302011-12-07T10:44:25.868+05:30Shared Preferences Example (Run application from last Activity after Home Press)<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; line-height: 15px;"><b><span class="Apple-style-span" style="color: #4c1130;">Shared Preferences</span></b></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"><br />
</span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Preferences are typically name value pairs. They can be stored as “Shared Preferences” across various activities in an application (note currently it cannot be shared across processes). Or it can be something that needs to be stored specific to an activity (which is not discussed here). <o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">The context object lets you retrieve </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">SharedPreferences</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"> through the method</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">Context.getSharedPreferences().</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"> <o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Courier New'; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">In my example, I will set 2 preferences i.e. </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">MyName</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"> and </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">MyWallpaper</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"> in one activity i.e</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">ManageSharedPref.java</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">. Retrieve these values in the next activity – </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">ViewSharedPrefs.java</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">. The second activity displays my preferred name in a list view and also resets the android wallpaper to the image that I had set as a preferred wallpaper in the first activity. When you run this application, if you come back to the home, you will see the wall paper is reset. <o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Here is the code in </span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">ManageSharesPrefs</span><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">:<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">SharedPreferences myPrefs = </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">.getSharedPreferences(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"myPrefs"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">,</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MODE_WORLD_READABLE</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> SharedPreferences.Editor prefsEditor = myPrefs.edit();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> prefsEditor.putString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_NAME</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Sai"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> prefsEditor.putString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_WALLPAPER</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"f664.PNG"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> prefsEditor.commit();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt; line-height: 15px;"> </span><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">First, I obtain a </span><span style="color: black; font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">SharedPreferences</span><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"> object making it readable by all. The first parameter is a name of a file that stores my preferences. This automatically creates the xml file if it does not exist and then stores in the same. <o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Next, I edit it. That creates an editor object, using which I input my preferences. Here, for the wall paper, I have put an image name. I also need to push the actual image file into the android storage which I do this way.<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">adb push <local> <remote><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Courier New'; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">In this case it is <o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt; line-height: 15px;">adb push f664.PNG /data/misc/wallpaper/f664.PNG<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Courier New'; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">This command creates a folder called wallpaper in /data/misc and copies the f664.PNG file from my current location to the android storage.<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">When I click the “View Shared Preferences” button, I am taken to the next activity. Here is the code in ViewSharedPrefs that gets executed:<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> SharedPreferences myPrefs = </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">.getSharedPreferences(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"myPrefs"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">,</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MODE_WORLD_READABLE</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> String prefName = myPrefs.getString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_NAME</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"nothing"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> String wallPaper = myPrefs.getString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_WALLPAPER</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">null</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">if</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">(wallPaper != </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">null</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">) {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">try</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Bitmap bm = BitmapFactory.<i>decodeFile</i>(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"/data/misc/wallpaper/"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">+wallPaper);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>d</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Wallpaper name is: "</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">+ wallPaper);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> setWallpaper(bm);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Toast.<i>makeText</i>(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Wall paper has been changed."</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> +</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"You may go to the home screen to view the same"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, Toast.</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">LENGTH_LONG</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">).show();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> } </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">catch</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> (FileNotFoundException fe){</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>e</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"File not found"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> } </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">catch</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> (IOException ie) {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>e</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">" IO Exception"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> }</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> }</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayList<String> results = </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">new</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayList<String>();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> results.add(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Your Preferred name is: "</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> + prefName);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">.setListAdapter(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">new</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayAdapter<String>(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, android.R.layout.</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">simple_list_item_1</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">,results));</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><br />
</div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">There are 3 steps to understand here:<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto; text-indent: -0.25in;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">1.<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Step 1: Retrieve the shared prefs data from the object.<o:p></o:p></span></div><div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto; text-indent: -0.25in;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: x-small;"><span style="font-size: 13px; line-height: 14px;"><br />
</span></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> SharedPreferences myPrefs = </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">.getSharedPreferences(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"myPrefs"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">,</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MODE_WORLD_READABLE</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> String prefName = myPrefs.getString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_NAME</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"nothing"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> String wallPaper = myPrefs.getString(</span><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">MY_WALLPAPER</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">null</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><br />
</div><div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto; text-indent: -0.25in;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">2.<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> Step 2: </span></span><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Display the name<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayList<String> results = </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">new</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayList<String>();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> results.add(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Your Preferred name is: "</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> + prefName);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">.setListAdapter(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">new</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> ArrayAdapter<String>(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, android.R.layout.</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">simple_list_item_1</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">,results));</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><br />
</div><div class="MsoListParagraph" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto; text-indent: -0.25in;"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">3.<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> Step 3: </span></span><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">Reset the wall paper.<o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">if</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">(wallPaper != </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">null</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">) {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">try</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Bitmap bm = BitmapFactory.<i>decodeFile</i>(</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"/data/misc/wallpaper/"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">+wallPaper);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>d</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Wallpaper name is: "</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">+ wallPaper);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> setWallpaper(bm);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Toast.<i>makeText</i>(</span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">this</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"Wall paper has been changed."</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> +</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"You may go to the home screen to view the same"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">, Toast.</span><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;">LENGTH_LONG</span></i><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">).show();</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> } </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">catch</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> (FileNotFoundException fe){</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>e</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">"File not found"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> } </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;">catch</span></b><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> (IOException ie) {</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> Log.<i>e</i>(getClass().getSimpleName(),</span><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 10pt;">" IO Exception"</span><span style="color: black; font-family: 'Courier New'; font-size: 10pt;">);</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> }</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> </span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; margin-bottom: 0in; text-align: -webkit-auto;"><span style="color: black; font-family: 'Courier New'; font-size: 10pt;"> }</span><span style="font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;">It is this simple. The complete code is available <a href="http://www.mediafire.com/?yzzmj4lwyyy" style="color: #336699; text-decoration: none;">here</a>.</span></div><div class="MsoNormal" style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 17px; text-align: -webkit-auto;"><span style="font-family: 'Trebuchet MS', sans-serif; font-size: 10pt; line-height: 15px;"><br />
</span></div><div class="MsoNormal" style="background-color: white; text-align: -webkit-auto;"><span class="Apple-style-span" style="color: #4c1130; font-family: 'Trebuchet MS', sans-serif;"><span class="Apple-style-span" style="line-height: 15px;">By help of Shered Prefrences we can solve the Problem of </span></span></div><h1 style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: 'Trebuchet MS', 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 1.3; margin-bottom: 7px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><a class="question-hyperlink" href="http://stackoverflow.com/questions/6364418/android-show-last-viewed-activity-when-press-home-button-app-shortcut" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: black; cursor: pointer; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;">Show last viewed Activity When press </a>Home </span></h1></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-27761997060254049862011-11-19T18:20:00.006+05:302011-11-19T18:21:25.487+05:30Android Add Permission Dynemically<div dir="ltr" style="text-align: left;" trbidi="on"><span class="normal" style="background-color: #e2e2e2; color: #3a3a3a; font-family: arial, sans-serif; font-size: 0.9em; text-align: -webkit-auto;">public abstract boolean </span><span class="sympad" style="background-color: #e2e2e2; color: #3a3a3a; font-family: arial, sans-serif; font-size: 14px; font-weight: bold; margin-right: 2px; text-align: -webkit-auto;">addPermission</span><span class="Apple-style-span" style="background-color: #e2e2e2; color: #3a3a3a; font-family: arial, sans-serif; font-size: 14px; font-weight: bold;"> </span><span class="normal" style="background-color: #e2e2e2; color: #3a3a3a; font-family: arial, sans-serif; font-size: 0.9em; text-align: -webkit-auto;">(<a href="http://developer.android.com/reference/android/content/pm/PermissionInfo.html" style="color: #006699;">PermissionInfo</a> info)</span><br />
<div class="jd-details api apilevel-1" style="background-color: white; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; font-family: arial, sans-serif; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"><div class="api-level" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #999999; float: right; font-size: 0.8em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: -25px; padding-bottom: 0px; padding-left: 7px; padding-right: 7px; padding-top: 0px;"><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Since: <a href="http://developer.android.com/guide/appendix/api-levels.html#level1" style="color: #999999; text-decoration: none;">API Level 1</a></div></div><div class="jd-details-descr" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 13px; margin-bottom: 0.5em; margin-left: 0.25em; margin-right: 0.25em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div class="jd-tagdata jd-tagdescr" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1em; margin-bottom: 0.75em; margin-left: 0px; margin-right: 0px; margin-top: 0.25em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Add a new dynamic permission to the system. For this to work, your package must have defined a permission tree through the <code style="color: #007000; line-height: 1em;"><a href="http://developer.android.com/reference/android/R.styleable.html#AndroidManifestPermissionTree" style="color: #006699;"><permission-tree></a></code> tag in its manifest. A package can only add permissions to trees that were defined by either its own package or another with the same user id; a permission is in a tree if it matches the name of the permission tree + ".": for example, "com.foo.bar" is a member of the permission tree "com.foo".</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">It is good to make your permission tree name descriptive, because you are taking possession of that entire set of permission names. Thus, it must be under a domain you control, with a suffix that will not match any normal permissions that may be declared in any applications that are part of that domain.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">New permissions must be added before any .apks are installed that use those permissions. Permissions you add through this method are remembered across reboots of the device. If the given permission already exists, the info you supply here will be used to update it.</div></div><div class="jd-tagdata" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.5em; margin-left: 1em; margin-right: 1em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><h5 class="jd-tagtitle" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #3a3a3a; font-size: 1em; margin-bottom: 0.65em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Parameters</h5><table class="jd-tagtable" style="border-bottom-width: 0px; border-collapse: collapse; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; empty-cells: show; font-size: 1em; margin-bottom: 1em; margin-left: 1em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><tbody style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<tr style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><th style="border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 10px; padding-right: 10px; padding-top: 2px; text-align: left; vertical-align: top;">info</th><td style="border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 10px; padding-right: 10px; padding-top: 2px; text-align: left; vertical-align: top;">Description of the permission to be added.</td></tr>
</tbody></table></div><div class="jd-tagdata" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.5em; margin-left: 1em; margin-right: 1em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><h5 class="jd-tagtitle" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #3a3a3a; font-size: 1em; margin-bottom: 0.65em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Returns</h5><ul class="nolist" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 1em; margin-left: 1em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Returns true if a new permission was created, false if an existing one was updated.</li>
</ul></div><div class="jd-tagdata" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.5em; margin-left: 1em; margin-right: 1em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><h5 class="jd-tagtitle" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #3a3a3a; font-size: 1em; margin-bottom: 0.65em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Throws</h5><table class="jd-tagtable" style="border-bottom-width: 0px; border-collapse: collapse; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; empty-cells: show; font-size: 1em; margin-bottom: 1em; margin-left: 1em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><tbody style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<tr style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><th style="border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 10px; padding-right: 10px; padding-top: 2px; text-align: left; vertical-align: top;"><a href="http://developer.android.com/reference/java/lang/SecurityException.html" style="color: #006699;">SecurityException</a></th><td style="border-bottom-style: none; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 10px; padding-right: 10px; padding-top: 2px; text-align: left; vertical-align: top;">if you are not allowed to add the given permission name.</td></tr>
</tbody></table></div><div class="jd-tagdata" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.5em; margin-left: 1em; margin-right: 1em; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><h5 class="jd-tagtitle" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #3a3a3a; font-size: 1em; margin-bottom: 0.65em; margin-left: 0px; margin-right: 0px; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">See Also</h5><ul class="nolist" style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; list-style-image: initial; list-style-position: initial; list-style-type: none; margin-bottom: 1em; margin-left: 1em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><code style="color: #007000; line-height: 1em;"><a href="http://developer.android.com/reference/android/content/pm/PackageManager.html#removePermission(java.lang.String)" style="color: #006699;">removePermission(String)</a></code></li>
</ul></div></div></div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-43422438025026797522011-11-17T11:02:00.000+05:302011-11-17T11:02:10.646+05:30Android Facebook API example using FBRocket<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<h1 class="title" style="background-color: white; color: #80ad40; font-family: arial; font-size: 20px; font-weight: normal; line-height: 1.2em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">Android Facebook API example using FBRocket</h1><div class="content-content" id="content-content" style="background-color: white; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"><div class="node odd full-node node-type-blog" id="node-1941" style="margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div class="inner" style="margin-bottom: 0px; margin-left: 12px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative;"><div class="content clearfix" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 890px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div class="topsy_widget_data topsy_theme_blue " id="topsy_id1-1-1-1-3-1-3-1-1-1-3-1-1-1-3-1-1-16-1-1-1" style="background-attachment: initial; background-clip: initial; background-color: initial; background-origin: initial; float: right; margin-bottom: 1em; margin-left: 1em; margin-right: 1em; margin-top: 0px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><div class="topsy-big" classname="topsy-big" style="float: none; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 50px;"><a class="topsy-big-retweet snap_noshots" classname="topsy-big-retweet snap_noshots" href="http://button.topsy.com/retweet?nick=Androidpeople&url=http%3A//www.androidpeople.com/android-facebook-api-example-using-fbrocket&title=Android+Facebook+API+example+using+FBRocket" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(51, 102, 153) !important; background-origin: initial !important; background-position-x: 0%; background-position-y: -20px !important; border-bottom-color: rgb(51, 102, 153) !important; border-bottom-left-radius: 3px 3px !important; border-bottom-right-radius: 3px 3px !important; border-left-color: rgb(51, 102, 153) !important; border-right-color: rgb(51, 102, 153) !important; border-top-color: rgb(51, 102, 153) !important; border-top-left-radius: 3px 3px !important; border-top-right-radius: 3px 3px !important; color: rgb(255, 255, 255) !important; display: block; font-family: Arial, Tahoma, Helvetica, sans-serif !important; font-size: 11px !important; line-height: 16px !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 2px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; text-align: center !important; text-decoration: none !important; text-shadow: rgb(42, 85, 128) 1px 1px 0px !important;" target="_blank">retweet</a></div></div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">This post is posted as per the request of many comments on <a href="http://www.androidpeople.com/android-post-status-to-twitter-using-jtwitter-example/" rel="nofollow" style="color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_blank">Android JTwitter Example.</a></div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Now let proceed ahead with Facebook using FBrocket.</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Using FB rocket we can update our facebook profile status from mobile application.</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Before we get into <a href="" id="AdBriteInlineAd_coding" name="AdBriteInlineAd_coding" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif); background-origin: initial; background-position: 50% 100%; background-repeat: repeat no-repeat; color: #006600; cursor: pointer; margin-bottom: -2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_top">coding</a> we got to make sure that we do the following <a href="" id="AdBriteInlineAd_steps" name="AdBriteInlineAd_steps" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif); background-origin: initial; background-position: 50% 100%; background-repeat: repeat no-repeat; color: #006600; cursor: pointer; margin-bottom: -2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_top">steps</a></div><ol style="font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1.5em; margin-left: 2em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><li style="line-height: 19px; margin-bottom: 2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Import the FBrocket JAR file to the eclipse project and add it to JAR libraries. Download here ( <a href="http://www.xeomax.net/fbrocket/download.php?d=bin&v=0.1a" rel="nofollow" style="color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_blank">http://www.xeomax.net/fbrocket/download.php?d=bin&v=0.1a</a> )</li>
<li style="line-height: 19px; margin-bottom: 2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Make sure you have created an application in<a href="http://www.facebook.com/developers/#!/developers/createapp.php" rel="nofollow" style="color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_blank">http://www.facebook.com/developers/#!/developers/createapp.php</a></li>
<li style="line-height: 19px; margin-bottom: 2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Note down <a href="" id="AdBriteInlineAd_application" name="AdBriteInlineAd_application" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif); background-origin: initial; background-position: 50% 100%; background-repeat: repeat no-repeat; color: #006600; cursor: pointer; margin-bottom: -2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_top">application</a> name and API key, do not reveal API key to anybody.</li>
</ol><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">[sourcecode language="java"]<br />
package org.androidpeople.facebook;</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">import net.xeomax.FBRocket.FBRocket;<br />
import net.xeomax.FBRocket.Facebook;<br />
import net.xeomax.FBRocket.LoginListener;<br />
import net.xeomax.FBRocket.ServerErrorException;<br />
import android.app.Activity;<br />
import android.os.Bundle;</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public class FacebookRocketExample extends Activity implements LoginListener {</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">private FBRocket fbRocket;</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shareFacebook();<br />
}</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public void shareFacebook() {<br />
fbRocket = new FBRocket(this, "Your App Name",<br />
"Your API Key");</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">if (fbRocket.existsSavedFacebook()) {<br />
fbRocket.loadFacebook();<br />
} else {<br />
fbRocket.login(R.layout.main);<br />
}<br />
}</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">@Override<br />
public void onLoginFail() {<br />
fbRocket.displayToast("Login failed!");<br />
fbRocket.login(R.layout.main);<br />
}</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">@Override<br />
public void onLoginSuccess(Facebook facebook) {<br />
// TODO Auto-generated method stub<br />
fbRocket.displayToast("Login success!");</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">try {<br />
<a href="" id="AdBriteInlineAd_facebook" name="AdBriteInlineAd_facebook" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif); background-origin: initial; background-position: 50% 100%; background-repeat: repeat no-repeat; color: #006600; cursor: pointer; margin-bottom: -2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_top">facebook</a>.setStatus("This is your status");<br />
fbRocket.displayDialog("Status Posted Successfully!! "<br />
+ <a href="" id="AdBriteInlineAd_Facebook" name="AdBriteInlineAd_Facebook" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif); background-origin: initial; background-position: 50% 100%; background-repeat: repeat no-repeat; color: #006600; cursor: pointer; margin-bottom: -2px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_top">facebook</a>.getStatus());<br />
} catch (ServerErrorException e) {<br />
if (e.notLoggedIn()) {<br />
fbRocket.login(R.layout.main);<br />
} else {<br />
System.out.println(e);<br />
}<br />
}<br />
}</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">}<br />
[/sourcecode]</div><div style="color: #515151; font-family: arial; font-size: 13px; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">Screenshots :<br />
<a href="http://www.androidpeople.com/wp-content/uploads/2010/07/facebook-androidpeople.png" rel="nofollow" style="color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"><img alt="" class="alignnone size-full wp-image-1455" height="480" src="http://www.androidpeople.com/wp-content/uploads/2010/07/facebook-androidpeople.png" style="border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-style: initial; border-top-width: 0px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;" title="facebook-androidpeople" width="320" /></a><a href="http://www.androidpeople.com/wp-content/uploads/2010/07/facebook1-androidpeople.png" rel="nofollow" style="color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;"><img alt="" class="alignnone size-full wp-image-1456" height="480" src="http://www.androidpeople.com/wp-content/uploads/2010/07/facebook1-androidpeople.png" style="border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-style: initial; border-top-width: 0px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;" title="facebook1-androidpeople" width="320" /></a></div><div style="color: #515151; font-family: arial; line-height: 22px; margin-bottom: 1em; margin-top: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><b>Download</b><span class="Apple-style-span" style="font-size: 13px;"> : This Example <a href="http://www.androidpeople.com/wp-content/uploads/2010/07/FacebookRocket.zip" target="_blank">Click Here</a></span></div></div></div></div></div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-41449476084982940402011-11-15T18:20:00.000+05:302011-11-15T18:20:45.443+05:30Delete file in Internal Storage<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<h3 class="post-title entry-title" style="background-color: white; font: normal normal normal 22px/normal 'Trebuchet MS', Trebuchet, Verdana, sans-serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0.75em; position: relative; text-align: -webkit-auto;"><span class="Apple-style-span" style="color: #4c1130;">Delete file in Internal Storage</span></h3><div class="post-header" style="background-color: white; color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 11px; line-height: 1.6; margin-bottom: 1.5em; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: -webkit-auto;"><div class="post-header-line-1"></div></div><div class="post-body entry-content" id="post-body-3590267553374369138" style="background-color: white; position: relative; text-align: -webkit-auto; width: 576px;"><span class="Apple-style-span" style="color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 1.4;">Here method deleteFile() delete the given file associated with this Context's application package.</span><br />
<div class="post-body entry-content" id="post-body-3590267553374369138" style="position: relative; width: 576px;"><span class="Apple-style-span" style="color: #666666; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif;"><span class="Apple-style-span" style="font-size: 22px;"><br />
</span></span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5aySvpvTxvMQPY4w7cRXi6lNXSf5dtCUzL643aNaZLX0Tw05vsLTBEnR8CZeFplO2AfHtw76BodPDqAF08l0Q0qrxPg-R0_z8Xe2SobzlUF2pbG0DVtsCKIu9CwKIYdHOwhhGpDuTPUyx/s1600/Internal+Storage_deletefile_01.png" style="color: #5421bb; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; text-decoration: none;"><img alt="Delete file in Internal Storage" border="0" id="BLOGGER_PHOTO_ID_5664820490034906242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5aySvpvTxvMQPY4w7cRXi6lNXSf5dtCUzL643aNaZLX0Tw05vsLTBEnR8CZeFplO2AfHtw76BodPDqAF08l0Q0qrxPg-R0_z8Xe2SobzlUF2pbG0DVtsCKIu9CwKIYdHOwhhGpDuTPUyx/s400/Internal+Storage_deletefile_01.png" style="-webkit-box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; border-color: initial; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(238, 238, 238); border-top-style: solid; border-top-width: 1px; border-width: initial; box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; cursor: pointer; display: block; height: 400px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; position: relative; text-align: center; width: 240px;" title="Delete file in Internal Storage" /></a><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm02Mxhz1V0lkfzS3tpUuPGdNJ4CHuBBIsNxIhOZ3ac8Ozj0VofmdjMfkbh3jXoCxKtzOpW8OHBgWUOUsEz9b4TsCvUhJ-6l606Cw1okp8wBqlGBWYIVmx1G4wwizAITXiDd4pZsNJ5ojS/s1600/Internal+Storage_deletefile_02.png" style="color: #5421bb; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; text-decoration: none;"><img alt="Delete file in Internal Storage" border="0" id="BLOGGER_PHOTO_ID_5664820438809366402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm02Mxhz1V0lkfzS3tpUuPGdNJ4CHuBBIsNxIhOZ3ac8Ozj0VofmdjMfkbh3jXoCxKtzOpW8OHBgWUOUsEz9b4TsCvUhJ-6l606Cw1okp8wBqlGBWYIVmx1G4wwizAITXiDd4pZsNJ5ojS/s400/Internal+Storage_deletefile_02.png" style="-webkit-box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; border-color: initial; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(238, 238, 238); border-top-style: solid; border-top-width: 1px; border-width: initial; box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; cursor: pointer; display: block; height: 400px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; position: relative; text-align: center; width: 240px;" title="Delete file in Internal Storage" /></a><br />
<br />
<pre style="border-bottom-color: black; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: black; border-left-style: solid; border-left-width: 1px; border-right-color: black; border-right-style: solid; border-right-width: 1px; border-top-color: black; border-top-style: solid; border-top-width: 1px; color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4;"><code><span style="color: black;">package com.exercise.AndroidInternalStorage;
<span class="IL_AD" id="IL_AD8" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">import</span> java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.<span class="IL_AD" id="IL_AD10" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Bundle</span>;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class AndroidInternalStorageActivity extends Activity {
EditText edFileName, edContent;
Button btnSave;
ListView listSavedFiles;
String[] SavedFiles;
/** Called <span class="IL_AD" id="IL_AD12" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">when the</span> activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
edFileName = (EditText)findViewById(R.id.filename);
edContent = (EditText)findViewById(R.id.content);
btnSave = (Button)findViewById(R.id.save);
listSavedFiles = (ListView)findViewById(R.id.list);
ShowSavedFiles();
btnSave.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated <span class="IL_AD" id="IL_AD9" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">method</span> stub
String fileName = edFileName.getText().<span class="IL_AD" id="IL_AD7" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">toString</span>();
String content = edContent.getText().toString();
FileOutputStream fos;
try {
fos = openFileOutput(fileName, Context.MODE_PRIVATE);
fos.write(content.getBytes());
fos.close();
Toast.makeText(
AndroidInternalStorageActivity.this,
fileName + " saved",
Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ShowSavedFiles();
}});
listSavedFiles.setOnItemClickListener(listSavedFilesOnItemClickListener);
}
void ShowSavedFiles(){
SavedFiles = getApplicationContext().fileList();
ArrayAdapter<String> adapter
= new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
SavedFiles);
listSavedFiles.setAdapter(adapter);
}
OnItemClickListener listSavedFilesOnItemClickListener
= new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
String clickedFile = (String) parent.getItemAtPosition(position);
OpenFileDialog(clickedFile);
}
};
void OpenFileDialog(final String file){
//Read file in <span class="IL_AD" id="IL_AD11" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Internal</span> Storage
FileInputStream fis;
String content = "";
try {
fis = openFileInput(file);
byte[] input = new byte[fis.available()];
while (fis.read(input) != -1) {}
content += new String(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//Create a custom Dialog
AlertDialog.Builder fileDialog
= new AlertDialog.Builder(AndroidInternalStorageActivity.this);
fileDialog.setTitle(file);
TextView textContent = new TextView(AndroidInternalStorageActivity.this);
textContent.setText(content);
LayoutParams textViewLayoutParams
= new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
textContent.setLayoutParams(textViewLayoutParams);
fileDialog.setView(textContent);
fileDialog.setPositiveButton("OK", null);
//<span class="IL_AD" id="IL_AD5" style="background-attachment: scroll !important; background-clip: initial !important; background-color: transparent !important; background-image: none !important; background-origin: initial !important; background-position: 0% 50%; background-repeat: repeat repeat !important; border-bottom-color: rgb(0, 153, 0) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; color: rgb(0, 153, 0) !important; cursor: pointer !important; display: inline !important; float: none !important; padding-bottom: 1px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static; text-decoration: underline !important;">Delete file</span> in Internal Storage
OnClickListener DeleteListener = new OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
deleteFile(file);
Toast.makeText(
AndroidInternalStorageActivity.this,
file + " deleted",
Toast.LENGTH_LONG).show();
ShowSavedFiles();
}
};
fileDialog.setNeutralButton("DELETE", DeleteListener);
fileDialog.show();
}
}</span></code></pre><br />
<br />
<a href="http://www.ziddu.com/download/16892945/AndroidInternalStorage_111018a.zip.html" style="color: #5421bb; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; text-decoration: none;"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5360544424610981522" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhppKQNzeFV8fQqgdIedx7YJI7x8om19IFIJlsMFgFFQi9tx5FLRR31MBr6S1mblo33N4yg_e5p3XSrNAZdPbNvf7UOKvOZ_1DaVxvmRz4hgnO95juJRaxklaDl945G4c3brulVNQBsl-TJ/s200/icons_download.gif" style="-webkit-box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-color: rgb(238, 238, 238); border-bottom-style: solid; border-bottom-width: 1px; border-color: initial; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(238, 238, 238); border-top-style: solid; border-top-width: 1px; border-width: initial; box-shadow: rgba(0, 0, 0, 0.0976563) 1px 1px 5px; height: 21px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; position: relative; width: 18px;" />Download the files</a><span class="Apple-style-span" style="color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small;"><span class="Apple-style-span" style="line-height: 1.4;">.</span></span></div></div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0tag:blogger.com,1999:blog-5778662197868112639.post-56813938820421756702011-11-07T18:00:00.000+05:302011-11-07T18:00:25.788+05:30Android Turn Off Screen<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<span class="Apple-style-span" style="color: #741b47;"><b>There are two choices for turning the screen off:</b></span><br />
<br />
PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);<br />
<br />
<b>// Choice 1</b><br />
manager.goToSleep(int amountOfTime);<br />
<b><br />
</b><br />
<b>// Choice 2</b><br />
PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Your Tag");<br />
wl.acquire();<br />
wl.release();<br />
You will probably need this permission too:<br />
<br />
<uses-permission android:name="android.permission.WAKE_LOCK" /><br />
<br />
<b>UPDATE:</b><br />
<br />
<span class="Apple-style-span" style="color: blue;">Try this method; android turns off the screen once the light level is low enough.</span><br />
<br />
WindowManager.LayoutParams params = getWindow().getAttributes();<br />
params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;<br />
params.screenBrightness = 0;<br />
getWindow().setAttributes(params);<br />
</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com2tag:blogger.com,1999:blog-5778662197868112639.post-62864501898821685972011-11-05T17:14:00.002+05:302011-11-07T09:55:16.582+05:30Android How can i call API periodically?<div dir="ltr" style="text-align: left;" trbidi="on"><b>If you want to call that API after 30 second again and again</b><br />
<b><br />
</b><br />
use Service with Broadcast receiver.<br />
Service will do your Task in Background but will not provide any UI so you need to register with Broadcast receiver.<br />
<br />
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #222222; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17px; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; word-wrap: break-word;"><b><a href="http://android-solution-sample.blogspot.com/search/label/Android%20Broadcast%20Receiver" style="color: #993200; text-decoration: none;">Check this Sample ,</a></b> this sample show how to repeat a task and update UI using Service and Broadcast receiver.</div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #222222; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17px; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; word-wrap: break-word;">Also <a href="http://www.vogella.de/articles/AndroidServices/article.html" rel="nofollow" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0077cc; cursor: pointer; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;">refer this tutorial</a> for further reference.</div></div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com1tag:blogger.com,1999:blog-5778662197868112639.post-31544024721288879072011-11-03T16:28:00.004+05:302011-11-03T16:30:04.888+05:30Find back stack activities in an android application?<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17px;"><span class="Apple-style-span" style="color: #4c1130;">The code below can be used to extract all the tasks and the top activity within each task in the back stack</span></span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17px;"><br />
</span><br />
ActivityManager m = (ActivityManager) ctx.getSystemService( ctx.ACTIVITY_SERVICE );<br />
List<RunningTaskInfo> runningTaskInfoList = m.getRunningTasks(10);<br />
Iterator<RunningTaskInfo> itr = runningTaskInfoList.iterator();<br />
while(itr.hasNext()){<br />
RunningTaskInfo runningTaskInfo = (RunningTaskInfo)itr.next();<br />
int id = runningTaskInfo.id;<br />
CharSequence desc= runningTaskInfo.description;<br />
int numOfActivities = runningTaskInfo.numActivities;<br />
String topActivity = runningTaskInfo.topActivity.getShortClassName();<br />
}</div>Programing Solutionhttp://www.blogger.com/profile/09310872784707130717noreply@blogger.com0