tag:blogger.com,1999:blog-8794419156309909922024-03-05T02:59:15.468-08:00Android Tutorial Android Tutorial for beginnersAnonymoushttp://www.blogger.com/profile/10788549951924956601noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-879441915630990992.post-51361302538200997492018-03-08T02:55:00.001-08:002018-03-08T02:55:50.276-08:00How To Build a Website Without Code Step by Step MASTER CLASS #1<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/qoIqqB2vhqw" width="480"></iframe>Internet Marketerhttp://www.blogger.com/profile/13925627520425736602noreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-50610923259856978902015-10-22T05:17:00.005-07:002016-02-14T06:04:36.556-08:00Download Samsung Galaxy S3/S III GT-I9300 User Manual<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7ADzhrdz5xvpwkIVYUPzJiSgtxD6jhdGtDHTa0zz3P0okeD69c18XU8hcoVaIiPlEiFj2cqkR684RHZjSlLdaxG6TwWj9R7mQgQgy2rbnf0lITgfry1aZhClCFbJP44IuHBndGjmB5u_G/s1600/GALAXY-S-III_8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7ADzhrdz5xvpwkIVYUPzJiSgtxD6jhdGtDHTa0zz3P0okeD69c18XU8hcoVaIiPlEiFj2cqkR684RHZjSlLdaxG6TwWj9R7mQgQgy2rbnf0lITgfry1aZhClCFbJP44IuHBndGjmB5u_G/s320/GALAXY-S-III_8.jpg" width="320" /></a></div>
<h2 style="clear: both; text-align: center;">
<b>Download Samsung Galaxy S3/S III GT-I9300 User Manual</b></h2>
<div class="separator" style="clear: both; text-align: center;">
Here's the Samsung Galaxy S III GT-I9300 User manual which may help you out in navigating your device through its full features and capabilities. The Samsung Galaxy S3 is powered with the latest Android Ice Cream Sandwich OS and browsing through it's system is quietly different from those older Android devices that runs with Gingerbread OS. This brand new Samsung flagship smartphone was sold in astonishing record - best selling in 2012 since it's released. So, you might be one of those millions user's worlwide probably looking for this manual.</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
Here' it is! download it from Samsung's official website </div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<a href="http://downloadcenter.samsung.com/content/UM/201206/20120608141856590/GT-I9300_UM_EU_Icecream_Eng_Rev.1.0_120607_Note.pdf" target="_blank"><b>Click Here </b></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
,everything you need to know about your newly owned Samsung Galaxy S3 is on it. Enjoy!</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ7aK85wbZJQu3GG-VU7qXgGUs5Q2jnYp7sq88inEDUcXjWt3cK1llb59GddZqp8CZXmcvZw6eiVldFfRHGfOUgAt8UaXtxrTp-Iu4AduwTVMWLZMRMpArnhiLhIgXLxlqV-hTZuyIVuKH/s1600/Samsung+Galaxy+S3+user+manual.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ7aK85wbZJQu3GG-VU7qXgGUs5Q2jnYp7sq88inEDUcXjWt3cK1llb59GddZqp8CZXmcvZw6eiVldFfRHGfOUgAt8UaXtxrTp-Iu4AduwTVMWLZMRMpArnhiLhIgXLxlqV-hTZuyIVuKH/s400/Samsung+Galaxy+S3+user+manual.jpg" width="283" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: center;">
<br /></div>Internet Marketerhttp://www.blogger.com/profile/13925627520425736602noreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-52536300720437105652013-08-23T01:15:00.001-07:002016-02-14T06:05:06.897-08:00Android Fundamentals <div dir="ltr" style="text-align: left;" trbidi="on">
From a developer's perspective, the fundamental building <b>blocks </b>/ <b>components </b>of Android are:<br />
1. Activities<br />
2. Services<br />
3. Broadcast Receivers<br />
4. Content Providers.<br />
<br />
<br />
The means of communication between the above mentioned components is through <br />
1. Intents<br />
2. Intent Filters<br />
<br />
<br />
The User Interface elements are by using what are called:<br />
1. Views<br />
2. Notifications<br />
<br />
<br />
Now, having broadly classified the basics, I would like to give a simple definition for each of them, before we can appreciate the need for each of them.<br />
<br />
<br />
<b>Activity </b>is the basic building block of every visible android application. It provides the means to render a UI. Every screen in an application is an activity by itself. Though they work together to present an application sequence, each activity is an independent entity.<br />
<br />
<br />
<b>Service </b>is another building block of android applications which does not provide a UI. It is a program that can run in the background for an indefinite period.<br />
<br />
<br />
<b>Broadcast Receiver</b> is yet another type of component that can receive and respond to any broadcast announcements. <br />
<br />
<br />
<b>Content Providers</b> are a separate league of components that expose a specific set of data to applications.<br />
<br />
<br />
While the understanding and knowledge of these four components is good enough to start development, the knowledge of the means of communication between the components is also essential. The platform designers have introduced a new conpect of communication through intents and intent filters.<br />
<br />
<br />
<b>Intents </b>are messages that are passed between components. So, is it equivalent to parameters passed to API calls? Yes, it is close to that. However, the fundamental differences between API calls and intents' way of invoking components is<br />
<br />
1. API calls are synchronous while intent-based invocation is asynchronous (mostly)<br />
2. API calls are bound at compile time while intent-based calls are run-time bound (mostly)<br />
<br />
<br />
It is these two differences that take Android platform to a different league. <br />
<br />
<br />
<b>NOTE</b>: Intents can be made to work exactly like API calls by using what are called explicit intents, which will be explained later. But more often than not, implicit intents are the way to go and that is what is explained here.<br />
<br />
<br />
<br />
One component that wants to invoke another has to only express its' "intent" to do a job. And any other component that exists and has claimed that it can do such a job through "intent-filters", is invoked by the android platform to accomplish the job. This means, both the components are not aware of each other's existence and can still work together to give the desired result for the end-user.<br />
<br />
<br />
This dotted line connection between components is achieved through the combination of intents, intent-filters and the android platform.<br />
<br />
<br />
This leads to huge possibilities like:<br />
<br />
1. Mix and match or rather plug and play of components at runtime<br />
2. Replacing the inbuilt android applications with custom developed applications<br />
3. Component level reuse within and across applications<br />
4. Service orientation to the most granular level, if I may say<br />
<br />
<br />
Now that the concept of intent has been introduced, let me get down to a more formal definition of Intent.<br />
<br />
<br />
<b>Intent </b>is a bundle of information, a passive data structure that holds an abstract description of the operation to be performed. (or in the case of broadcasts, a description of an event that has happened and is being announced).<br />
<br />
<br />
There are 2 types of intents which I intend to detail in the next part of this series. Before winding up part 1, I would finally also give you a formal definition of Intent filters.<br />
<br />
<br />
<b>Intent filters</b> are the means through which a component advertizes its own capabilities to handle specific job/operations to the android platform.</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-879441915630990992.post-19830615425786468962013-05-22T22:54:00.000-07:002016-02-14T06:05:15.713-08:00Detect Battery Info.The app simple detect battery level, voltage, temperature, technology, charging status, and health of the battery.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhDpEevvYkCMFxxxF3Zo7YyRAokLdTgHcPRJlXGnwGCQSNjwvtYwkXjPQlWX0R_lzZRFx6ENAgGzD3wOMhAY-oWdV9mkux9hwn6qJdRPNiuxn26vWgeGOBzzWLUy-Une7_uT0r9zRK238/s1600/device-2013-05-23-112017.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhDpEevvYkCMFxxxF3Zo7YyRAokLdTgHcPRJlXGnwGCQSNjwvtYwkXjPQlWX0R_lzZRFx6ENAgGzD3wOMhAY-oWdV9mkux9hwn6qJdRPNiuxn26vWgeGOBzzWLUy-Une7_uT0r9zRK238/s1600/device-2013-05-23-112017.png" height="320" width="212" /></a></div>
<br />
<br />
<b>Activity</b><br />
<br />
<br />
public class MainActivity extends Activity {<br /><br /> private TextView batteryLevel, batteryVoltage, batteryTemperature,<br /> batteryTechnology, batteryStatus, batteryHealth;<br /><br /> /** Called when the activity is first created. */<br /> @Override<br /> public void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_main);<br /><br /> batteryLevel = (TextView) findViewById(R.id.batterylevel);<br /> batteryVoltage = (TextView) findViewById(R.id.batteryvoltage);<br /> batteryTemperature = (TextView) findViewById(R.id.batterytemperature);<br /> batteryTechnology = (TextView) findViewById(R.id.batterytechology);<br /> batteryStatus = (TextView) findViewById(R.id.batterystatus);<br /> batteryHealth = (TextView) findViewById(R.id.batteryhealth);<br /><br /> this.registerReceiver(this.myBatteryReceiver, new IntentFilter(<br /> Intent.ACTION_BATTERY_CHANGED));<br /> }<br /><br /> private BroadcastReceiver myBatteryReceiver = new BroadcastReceiver() {<br /><br /> @Override<br /> public void onReceive(Context arg0, Intent arg1) {<br /> // TODO Auto-generated method stub<br /><br /> if (arg1.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {<br /> batteryLevel.setText("Level: "<br /> + String.valueOf(arg1.getIntExtra("level", 0)) + "%");<br /> batteryVoltage<br /> .setText("Voltage: "<br /> + String.valueOf((float) arg1.getIntExtra(<br /> "voltage", 0) / 1000) + "V");<br /> batteryTemperature.setText("Temperature: "<br /> + String.valueOf((float) arg1.getIntExtra(<br /> "temperature", 0) / 10) + "c");<br /> batteryTechnology.setText("Technology: "<br /> + arg1.getStringExtra("technology"));<br /><br /> int status = arg1.getIntExtra("status",<br /> BatteryManager.BATTERY_STATUS_UNKNOWN);<br /> String strStatus;<br /> if (status == BatteryManager.BATTERY_STATUS_CHARGING) {<br /> strStatus = "Charging";<br /> } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {<br /> strStatus = "Dis-charging";<br /> } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {<br /> strStatus = "Not charging";<br /> } else if (status == BatteryManager.BATTERY_STATUS_FULL) {<br /> strStatus = "Full";<br /> } else {<br /> strStatus = "Unknown";<br /> }<br /> batteryStatus.setText("Status: " + strStatus);<br /><br /> int health = arg1.getIntExtra("health",<br /> BatteryManager.BATTERY_HEALTH_UNKNOWN);<br /> String strHealth;<br /> if (health == BatteryManager.BATTERY_HEALTH_GOOD) {<br /> strHealth = "Good";<br /> } else if (health == BatteryManager.BATTERY_HEALTH_OVERHEAT) {<br /> strHealth = "Over Heat";<br /> } else if (health == BatteryManager.BATTERY_HEALTH_DEAD) {<br /> strHealth = "Dead";<br /> } else if (health == BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE) {<br /> strHealth = "Over Voltage";<br /> } else if (health == BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE) {<br /> strHealth = "Unspecified Failure";<br /> } else {<br /> strHealth = "Unknown";<br /> }<br /> batteryHealth.setText("Health: " + strHealth);<br /><br /> }<br /> }<br /><br /> };<br />}<br />
<br />
<b>XML activity_main.xml</b><br />
<br />
<?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> android:orientation="vertical"<br /> android:layout_width="fill_parent"<br /> android:layout_height="fill_parent"<br /> ><br /><TextView <br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content" <br /> android:text="hello"<br /> /><br /><TextView <br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Battery Info." <br /> /><br /><TextView <br /> android:id="@+id/batterylevel"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Battery Level:" <br /> /><br /><TextView <br /> android:id="@+id/batteryvoltage"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Battery Voltage:" <br /> /><br /><TextView <br /> android:id="@+id/batterytemperature"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Battery Temperature:" <br /> /><br /><TextView <br /> android:id="@+id/batterytechology"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Technology:" <br /> /><br /><TextView <br /> android:id="@+id/batterystatus"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Status:" <br /> /><br /><TextView <br /> android:id="@+id/batteryhealth"<br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content"<br /> android:text="Health:" <br /> /><br /></LinearLayout><br /><br />
<br />
<br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-879441915630990992.post-4278028515590637912013-05-21T23:33:00.003-07:002016-02-14T06:05:24.414-08:00Android Enable GPS (Check and prompt user to enable GPS)<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; display: inline ! important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">To check if the GPS have been enabled or not, the following code can be used:</span><br />
<br style="background-color: white; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" />
<b><span style="background-color: white; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: italic; font-variant: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);</span></b><br />
<br style="background-color: white; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" />
<span style="background-color: white; display: inline ! important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">If it's empty, means the GPS have not been enabled. You can start activity with intent</span><span style="background-color: white; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: italic; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Settings.ACTION_SECURITY_SETTINGS</span><span style="background-color: white; display: inline ! important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">, to switch to GPS setting page.</span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXW2eOljzYnr7WleRki86Q6zt12_de1M8sLc4HTFAEwUdzmVH-2Q4Pvi0LU_bAOjGYALlwleuZLsZKV2aVoASrG__0NGntD6FmCVE2SLlXpHG4dWlGbYAUsGF69_k7Tu7dAiMHIFYzGt8/s1600/AndroidEnableGPS_01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXW2eOljzYnr7WleRki86Q6zt12_de1M8sLc4HTFAEwUdzmVH-2Q4Pvi0LU_bAOjGYALlwleuZLsZKV2aVoASrG__0NGntD6FmCVE2SLlXpHG4dWlGbYAUsGF69_k7Tu7dAiMHIFYzGt8/s1600/AndroidEnableGPS_01.png" height="320" width="216" /></a></div>
<br />
<br />
<b><span style="background-color: white; display: inline ! important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">Activity</span></b><br />
<br />
<span style="background-color: white; display: inline ! important; float: none; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">import android.app.Activity;<br />import android.content.Intent;<br />import android.os.Bundle;<br />import android.provider.Settings;<br />import android.widget.Toast;<br /><br />public class AndroidEnableGPS extends Activity {<br /> /** Called when the activity is first created. */<br /> @Override<br /> public void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.main);<br /> <br /> CheckEnableGPS();<br /> }<br /> <br /> private void CheckEnableGPS(){<br /> String provider = Settings.Secure.getString(getContentResolver(),<br /> Settings.Secure.LOCATION_PROVIDERS_ALLOWED);<br /> if(!provider.equals("")){<br /> //GPS Enabled<br /> Toast.makeText(AndroidEnableGPS.this, "GPS Enabled: " + provider,<br /> Toast.LENGTH_LONG).show();<br /> }else{<br /> Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);<br /> startActivity(intent);<br /> }<br /><br /> }<br />}</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtZRc1LCeIxn4HiQ9-yvNpCx46-cVw7r3YXaR35IPjxIK7a5N0YgotDn6YGA-uWcfWewFK5QJscynsIbSRiqx_Vx7U_O8STZjiz7zGTxmE55kpZBenh8W-U24S8QmjT7hRwubxuEn8Oh0/s1600/AndroidEnableGPS_02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtZRc1LCeIxn4HiQ9-yvNpCx46-cVw7r3YXaR35IPjxIK7a5N0YgotDn6YGA-uWcfWewFK5QJscynsIbSRiqx_Vx7U_O8STZjiz7zGTxmE55kpZBenh8W-U24S8QmjT7hRwubxuEn8Oh0/s1600/AndroidEnableGPS_02.png" height="320" width="220" /></a></div>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-879441915630990992.post-4994897826693965572013-05-21T23:10:00.000-07:002013-05-21T23:35:45.279-07:00Android Location New Features<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/Bte_GHuxUGc" width="560"></iframe>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-52108579605616294542013-04-07T23:44:00.001-07:002016-02-14T06:05:57.017-08:00Android Notifications<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Android allows to put notification into the titlebar of your application. The user can expand the notification bar and by selecting the notification the user can trigger another activity.<br />
<br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="http://developer.android.com/reference/android/app/NotificationManager.html" target="_blank">Notifications</a> in Android are represented by the<span class="Apple-converted-space"> </span></span><code class="code" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">Notification</code><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span>class.</span><br />
<br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">The<span class="Apple-converted-space"> </span></span><a href="http://notification.builder/"><code class="code" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">Notification.Builder</code></a><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"><a href="http://developer.android.com/reference/android/app/Notification.Builder.html" target="_blank">http://developer.android.com/reference/android/app/Notification.Builder.html</a> </span>provides an builder interface to create an<span class="Apple-converted-space"> </span></span><code class="code" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">Notification</code><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="Apple-converted-space"> </span>object.</span></span><br />
<br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><b>Activity-MainActivity.java</b> </span></span><br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span></span><br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> private static final int MY_NOTIFICATION_ID = 1;<br /> private NotificationManager notificationManager;<br /> private Notification myNotification;<br /> private final String myBlog = "http://niravranpara.blogspot.com/"; </span></span><br />
<br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> buttonSend.setOnClickListener(new Button.OnClickListener() {<br /><br /> @Override<br /> public void onClick(View arg0) {<br /> // TODO Auto-generated method stub<br /> notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);<br /> myNotification = new Notification(R.drawable.ic_launcher,<br /> "Notification!", System.currentTimeMillis());<br /> Context context = getApplicationContext();<br /> String notificationTitle = "Exercise of Notification!";<br /> String notificationText = "http://niravranpara.blogspot.com/";<br /> Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri<br /> .parse(myBlog));<br /> PendingIntent pendingIntent = PendingIntent.getActivity(<br /> MainActivity.this, 0, myIntent,<br /> Intent.FLAG_ACTIVITY_NEW_TASK);<br /> myNotification.defaults |= Notification.DEFAULT_SOUND;<br /> myNotification.flags |= Notification.FLAG_AUTO_CANCEL;<br /> myNotification.setLatestEventInfo(context, notificationTitle,<br /> notificationText, pendingIntent);<br /> notificationManager.notify(MY_NOTIFICATION_ID, myNotification);<br /><br /> }<br /> });</span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLVLmQNdUT3eRCNuWcJHI3wLYxjo1FVhPi7VMGezfvHo1jcZ3q1eKuzre0pfBajot9C02bVrd9cdftEUPKcUt9X_LZQqQ9Hq9iYSKrmuqC4B658_aQMYtq5NEeKOr8QBavUI6JufE3WvQ/s1600/device-2013-04-08-121216.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLVLmQNdUT3eRCNuWcJHI3wLYxjo1FVhPi7VMGezfvHo1jcZ3q1eKuzre0pfBajot9C02bVrd9cdftEUPKcUt9X_LZQqQ9Hq9iYSKrmuqC4B658_aQMYtq5NEeKOr8QBavUI6JufE3WvQ/s1600/device-2013-04-08-121216.png" width="213" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<uses-permission android:name="android.permission.VIBRATE"/> </div>
<br />
<br />
<br />
<span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="background-color: white; color: black; display: inline; float: none; font-family: "lato" , "arial" , sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span></span>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-879441915630990992.post-46617309404005279862013-04-02T00:02:00.001-07:002016-02-14T06:06:21.129-08:00Android get current GPS location <script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
You can Find location either<span class="Apple-converted-space"> GPS_PROVIDER or NETWORK_PROVIDER </span><code style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 1px 5px; vertical-align: baseline;"></code></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
Overview of<span class="Apple-converted-space"> </span><span class="Apple-converted-space"><a href="http://developer.android.com/guide/topics/location/index.html" target="_blank">location services</a> </span>in Android , <span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><a href="http://developer.android.com/reference/android/location/LocationManager.html" target="_blank">LocationManager </a>class at the heart of location services in Android.</span></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
Here is one example which try to find location using GPS , if your GPS not available then try to use network for find location</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<b>Demo Code</b> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<b>Activity - AndroidGPSTrackingActivity.java</b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
public class AndroidGPSTrackingActivity extends Activity {<br />
<br />
Button btnShowLocation;<br />
<br />
// GPSTracker class<br />
GPSTracker gps;<br />
<br />
@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.main);<br />
<br />
btnShowLocation = (Button) findViewById(R.id.btnShowLocation);<br />
<br />
// show location button click event<br />
btnShowLocation.setOnClickListener(new View.OnClickListener() {<br />
<br />
@Override<br />
public void onClick(View arg0) { <br />
// create class object<br />
gps = new GPSTracker(AndroidGPSTrackingActivity.this);<br />
<br />
// check if GPS enabled <br />
if(gps.canGetLocation()){<br />
<br />
double latitude = gps.getLatitude();<br />
double longitude = gps.getLongitude();<br />
<br />
// \n is for new line<br />
Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show(); <br />
}else{<br />
// can't get location<br />
// GPS or Network is not enabled<br />
// Ask user to enable GPS/network in settings<br />
gps.showSettingsAlert();<br />
}<br />
<br />
}<br />
});<br />
}<br />
<br />
}</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAfvhCf-vVa5DxJXbnQ1JFDaiA7lH1T4ebhELKVnGXMoERV_63BHjmTOUnE5fnGuNkbDlA68tYuV4uO3IIYaQvMRtLuq6z2anS0vi4Q3mLfoS4lYo2VqpxVJKRgmuhyphenhyphencrzArtUUbv5GHE/s1600/location.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAfvhCf-vVa5DxJXbnQ1JFDaiA7lH1T4ebhELKVnGXMoERV_63BHjmTOUnE5fnGuNkbDlA68tYuV4uO3IIYaQvMRtLuq6z2anS0vi4Q3mLfoS4lYo2VqpxVJKRgmuhyphenhyphencrzArtUUbv5GHE/s1600/location.png" height="320" width="213" /></a></div>
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<b>GPSTracke.java</b> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
public class GPSTracker extends Service implements LocationListener {<br />
<br />
private final Context mContext;<br />
<br />
// flag for GPS status<br />
boolean isGPSEnabled = false;<br />
<br />
// flag for network status<br />
boolean isNetworkEnabled = false;<br />
<br />
// flag for GPS status<br />
boolean canGetLocation = false;<br />
<br />
Location location; // location<br />
double latitude; // latitude<br />
double longitude; // longitude<br />
<br />
// The minimum distance to change Updates in meters<br />
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters<br />
<br />
// The minimum time between updates in milliseconds<br />
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute<br />
<br />
// Declaring a Location Manager<br />
protected LocationManager locationManager;<br />
<br />
public GPSTracker(Context context) {<br />
this.mContext = context;<br />
getLocation();<br />
}<br />
<br />
public Location getLocation() {<br />
try {<br />
locationManager = (LocationManager) mContext<br />
.getSystemService(LOCATION_SERVICE);<br />
<br />
// getting GPS status<br />
isGPSEnabled = locationManager<br />
.isProviderEnabled(LocationManager.GPS_PROVIDER);<br />
<br />
// getting network status<br />
isNetworkEnabled = locationManager<br />
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);<br />
<br />
if (!isGPSEnabled && !isNetworkEnabled) {<br />
// no network provider is enabled<br />
} else {<br />
this.canGetLocation = true;<br />
if (isNetworkEnabled) {<br />
locationManager.requestLocationUpdates(<br />
LocationManager.NETWORK_PROVIDER,<br />
MIN_TIME_BW_UPDATES,<br />
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);<br />
Log.d("Network", "Network");<br />
if (locationManager != null) {<br />
location = locationManager<br />
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);<br />
if (location != null) {<br />
latitude = location.getLatitude();<br />
longitude = location.getLongitude();<br />
}<br />
}<br />
}<br />
// if GPS Enabled get lat/long using GPS Services<br />
if (isGPSEnabled) {<br />
if (location == null) {<br />
locationManager.requestLocationUpdates(<br />
LocationManager.GPS_PROVIDER,<br />
MIN_TIME_BW_UPDATES,<br />
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);<br />
Log.d("GPS Enabled", "GPS Enabled");<br />
if (locationManager != null) {<br />
location = locationManager<br />
.getLastKnownLocation(LocationManager.GPS_PROVIDER);<br />
if (location != null) {<br />
latitude = location.getLatitude();<br />
longitude = location.getLongitude();<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
} catch (Exception e) {<br />
e.printStackTrace();<br />
}<br />
<br />
return location;<br />
}<br />
<br />
/**<br />
* Stop using GPS listener<br />
* Calling this function will stop using GPS in your app<br />
* */<br />
public void stopUsingGPS(){<br />
if(locationManager != null){<br />
locationManager.removeUpdates(GPSTracker.this);<br />
} <br />
}<br />
<br />
/**<br />
* Function to get latitude<br />
* */<br />
public double getLatitude(){<br />
if(location != null){<br />
latitude = location.getLatitude();<br />
}<br />
<br />
// return latitude<br />
return latitude;<br />
}<br />
<br />
/**<br />
* Function to get longitude<br />
* */<br />
public double getLongitude(){<br />
if(location != null){<br />
longitude = location.getLongitude();<br />
}<br />
<br />
// return longitude<br />
return longitude;<br />
}<br />
<br />
/**<br />
* Function to check GPS/wifi enabled<br />
* @return boolean<br />
* */<br />
public boolean canGetLocation() {<br />
return this.canGetLocation;<br />
}<br />
<br />
/**<br />
* Function to show settings alert dialog<br />
* On pressing Settings button will lauch Settings Options<br />
* */<br />
public void showSettingsAlert(){<br />
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);<br />
<br />
// Setting Dialog Title<br />
alertDialog.setTitle("GPS is settings");<br />
<br />
// Setting Dialog Message<br />
alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");<br />
<br />
// On pressing Settings button<br />
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {<br />
public void onClick(DialogInterface dialog,int which) {<br />
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);<br />
mContext.startActivity(intent);<br />
}<br />
});<br />
<br />
// on pressing cancel button<br />
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {<br />
public void onClick(DialogInterface dialog, int which) {<br />
dialog.cancel();<br />
}<br />
});<br />
<br />
// Showing Alert Message<br />
alertDialog.show();<br />
}<br />
<br />
@Override<br />
public void onLocationChanged(Location location) {<br />
}<br />
<br />
@Override<br />
public void onProviderDisabled(String provider) {<br />
}<br />
<br />
@Override<br />
public void onProviderEnabled(String provider) {<br />
}<br />
<br />
@Override<br />
public void onStatusChanged(String provider, int status, Bundle extras) {<br />
}<br />
<br />
@Override<br />
public IBinder onBind(Intent arg0) {<br />
return null;<br />
}<br />
<br />
}</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<b>Layout - main.xml</b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<?xml version="1.0" encoding="utf-8"?><br />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="fill_parent"<br />
android:layout_height="fill_parent"<br />
android:orientation="vertical" ><br />
<br />
<Button android:id="@+id/btnShowLocation" <br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:text="Show Location"<br />
android:layout_centerVertical="true"<br />
android:layout_centerHorizontal="true"/><br />
<br />
</RelativeLayout></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<b><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <br /> <uses-permission android:name="android.permission.INTERNET" /></b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; background-position: initial initial; background-repeat: initial initial; border: 0px; clear: both; color: black; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 1em; orphans: auto; padding: 0px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: auto; word-spacing: 0px; word-wrap: break-word;">
<br /></div>
<code style="background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pln" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"></span></code>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com18tag:blogger.com,1999:blog-879441915630990992.post-86367340906145695262013-03-31T23:13:00.000-07:002016-02-14T06:06:33.311-08:00Android Internal and External storage<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<ul>
<li>Android Internal Storage </li>
</ul>
<ul><ul>
<li> Internal storage are private to your application and other applications cannot access them (nor can the user). </li>
</ul>
</ul>
<ul><ul>
<li> When the user uninstalls your application, these files are removed. </li>
</ul>
</ul>
<ul>
<li> Android External Storage</li>
</ul>
<ul><ul>
<li> External storage such as SD card can also store application data.</li>
</ul>
</ul>
<ul><ul>
<li> There's no security enforced upon files you save to the external storage. </li>
</ul>
</ul>
<ul><ul>
<li> All applications can read and write files placed on the external storage and the user can remove them. </li>
</ul>
</ul>
<ul><ul>
<li><b> You need Read and Write permission in External Storage</b></li>
</ul>
</ul>
In this example we are going to save data from an EditText to both Internal Storage and External Storage, and then try to get the data back from the respective storage places. <br />
<br />
<b><span style="color: red;"> FileOutputStream :For save Data<br /> FileInputStream :For Display data</span> </b><br />
<br />
<br />
Layout - <b>activity_main.xml</b><br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="fill_parent"<br />
android:layout_height="fill_parent"<br />
android:orientation="vertical" ><br />
<br />
<TextView<br />
android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:text="Storage Demo" /><br />
<br />
<EditText<br />
android:id="@+id/InputText"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:ems="10"<br />
android:gravity="top|left"<br />
android:inputType="textMultiLine"<br />
android:lines="5"<br />
android:minLines="2"<br />
android:text="Internal and External Storage" ><br />
<br />
<requestFocus /><br />
</EditText><br />
<br />
<Button<br />
android:id="@+id/InternalStorageSave"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:text="Internal Storage(Save)" /><br />
<br />
<Button<br />
android:id="@+id/InternalStorageGet"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:text="Internal Storage(Display)" /><br />
<br />
<Button<br />
android:id="@+id/ExternalStorageSave"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:text="External Storage(Save)" /><br />
<br />
<Button<br />
android:id="@+id/ExternalStorageGet"<br />
android:layout_width="match_parent"<br />
android:layout_height="wrap_content"<br />
android:text="External Storage(Displays)" /><br />
<br />
<TextView<br />
android:id="@+id/responseText"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:padding="5dp"<br />
android:text=""<br />
android:textAppearance="?android:attr/textAppearanceMedium" /><br />
<br />
</LinearLayout><br />
<br />
Activity - MainActivity.java<br />
<br />
import java.io.BufferedReader;<br />
import java.io.DataInputStream;<br />
import java.io.File;<br />
import java.io.FileInputStream;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.InputStreamReader;<br />
<br />
import android.app.Activity;<br />
import android.content.Context;<br />
import android.content.ContextWrapper;<br />
import android.os.Bundle;<br />
import android.os.Environment;<br />
import android.view.View;<br />
import android.view.View.OnClickListener;<br />
import android.widget.Button;<br />
import android.widget.EditText;<br />
import android.widget.TextView;<br />
<br />
<br />
<br />
public class MainActivity extends Activity implements OnClickListener {<br />
<br />
private String filename = "StorageFile.txt";<br />
private String filepath = "FileStorage";<br />
File myInternalFile;<br />
File myExternalFile;<br />
<br />
@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.activity_main);<br />
<br />
ContextWrapper contextWrapper = new ContextWrapper(<br />
getApplicationContext());<br />
File directory = contextWrapper.getDir(filepath, Context.MODE_PRIVATE);<br />
myInternalFile = new File(directory, filename);<br />
<br />
Button saveToInternalStorage = (Button) findViewById(R.id.InternalStorageSave);<br />
saveToInternalStorage.setOnClickListener(this);<br />
<br />
Button readFromInternalStorage = (Button) findViewById(R.id.InternalStorageGet);<br />
readFromInternalStorage.setOnClickListener(this);<br />
<br />
Button saveToExternalStorage = (Button) findViewById(R.id.ExternalStorageSave);<br />
saveToExternalStorage.setOnClickListener(this);<br />
<br />
Button readFromExternalStorage = (Button) findViewById(R.id.ExternalStorageGet);<br />
readFromExternalStorage.setOnClickListener(this);<br />
<br />
// check if external storage is available and not read only<br />
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {<br />
saveToExternalStorage.setEnabled(false);<br />
} else {<br />
myExternalFile = new File(getExternalFilesDir(filepath), filename);<br />
}<br />
<br />
}<br />
<br />
public void onClick(View v) {<br />
<br />
EditText myInputText = (EditText) findViewById(R.id.InputText);<br />
TextView responseText = (TextView) findViewById(R.id.responseText);<br />
String myData = "";<br />
<br />
switch (v.getId()) {<br />
case R.id.InternalStorageSave:<br />
try {<br />
FileOutputStream fos = new FileOutputStream(myInternalFile); // save<br />
fos.write(myInputText.getText().toString().getBytes());<br />
fos.close();<br />
} catch (IOException e) {<br />
e.printStackTrace();<br />
}<br />
myInputText.setText("");<br />
responseText.setText("Saved to Internal Storage.(StorageFile.txt)");<br />
break;<br />
<br />
case R.id.InternalStorageGet:<br />
try {<br />
FileInputStream fis = new FileInputStream(myInternalFile); // display<br />
DataInputStream in = new DataInputStream(fis);<br />
BufferedReader br = new BufferedReader(<br />
new InputStreamReader(in));<br />
String strLine;<br />
while ((strLine = br.readLine()) != null) {<br />
myData = myData + strLine;<br />
}<br />
in.close();<br />
} catch (IOException e) {<br />
e.printStackTrace();<br />
}<br />
myInputText.setText(myData);<br />
responseText<br />
.setText("Data retrieved from Internal Storage.(StorageFile.txt)");<br />
<br />
break;<br />
<br />
case R.id.ExternalStorageSave:<br />
try {<br />
FileOutputStream fos = new FileOutputStream(myExternalFile);<br />
fos.write(myInputText.getText().toString().getBytes());<br />
fos.close();<br />
} catch (IOException e) {<br />
e.printStackTrace();<br />
}<br />
myInputText.setText("");<br />
responseText.setText("Saved to External Storage.(StorageFile.txt)");<br />
break;<br />
<br />
case R.id.ExternalStorageGet:<br />
try {<br />
FileInputStream fis = new FileInputStream(myExternalFile);<br />
DataInputStream in = new DataInputStream(fis);<br />
BufferedReader br = new BufferedReader(<br />
new InputStreamReader(in));<br />
String strLine;<br />
while ((strLine = br.readLine()) != null) {<br />
myData = myData + strLine;<br />
}<br />
in.close();<br />
} catch (IOException e) {<br />
e.printStackTrace();<br />
}<br />
myInputText.setText(myData);<br />
responseText<br />
.setText("Data retrieved from Internal Storage.(StorageFile.txt)");<br />
break;<br />
<br />
}<br />
}<br />
<br />
private static boolean isExternalStorageReadOnly() {<br />
String extStorageState = Environment.getExternalStorageState();<br />
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {<br />
return true;<br />
}<br />
return false;<br />
}<br />
<br />
private static boolean isExternalStorageAvailable() {<br />
String extStorageState = Environment.getExternalStorageState();<br />
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {<br />
return true;<br />
}<br />
return false;<br />
}<br />
<br />
}<br />
<b><br /></b>
<b><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><br /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/></b><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57YZQ8p3bLJc0aNlIze-py6Wxudd04gLCO3skBU5_xhIbPzmYZQ9xdn0PUCUCqeN06eU15yXXq5PfuHyCZG7bEje-DKMivQU2m56AxVxzxgRSxQBEuY06NezEQz8xI1qVTBxvr2nmT1c/s1600/device-2013-04-01-114142.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57YZQ8p3bLJc0aNlIze-py6Wxudd04gLCO3skBU5_xhIbPzmYZQ9xdn0PUCUCqeN06eU15yXXq5PfuHyCZG7bEje-DKMivQU2m56AxVxzxgRSxQBEuY06NezEQz8xI1qVTBxvr2nmT1c/s1600/device-2013-04-01-114142.png" height="320" width="213" /></a></div>
<br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-879441915630990992.post-12380916373196077592013-03-21T23:23:00.000-07:002016-02-14T06:06:41.567-08:00Android get lat and long from address<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<br />
<br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">You can use the <a href="https://developers.google.com/maps/documentation/javascript/services#Geocoding" target="_blank">Google Geocoder service</a> in the <a href="https://developers.google.com/maps/documentation/geocoding/#JSON" target="_blank">Google Maps API</a> to convert from your location name to a latitude and longitude. So you need some code like</span><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"></span><br />
<br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">The idea is simple. Make a request to Google Map server and it will return an JSON or XML. Then, parse the JSON to get Lat and Long.</span><br />
<br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; color: black; display: inline !important; float: none; font-family: Georgia, Verdana, Times; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 29.015625px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"> </span>I have used </span><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: black; display: inline !important; float: none; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><a href="https://developers.google.com/maps/documentation/geocoding/#JSON" target="_blank">Google Maps API</a> Here.</span> </span><br />
<br />
<br />
// <b>JSON Node names</b><br />
private static final String TAG_RESULTS = "results";<br />
private static final String TAG_GEOMETRY = "geometry";<br />
private static final String TAG_VIEWPORT = "viewport";<br />
private static final String TAG_NORTHEAST = "northeast";<br />
private static final String TAG_LAT = "lat";<br />
private static final String TAG_LNG = "lng";<br />
// contacts JSONArray<br />
JSONArray results = null;<br />
<br />
<a href="http://niravranpara.blogspot.in/2013/03/android-get-lat-and-long-from-address.html" target="_blank"><b>Android get lat and long from address</b></a><br />
<br />
// Creating JSON Parser instance<br />
JSONParser jParser = new JSONParser();<br />
<br />
address = "Rajkot, Gujarat, India";<br />
<br />
address = address.replaceAll(" ", "%20");<br />
url = "http://maps.googleapis.com/maps/api/geocode/json?address="<br />
+ address + "&sensor=true";<br />
<br />
// getting JSON string from URL<br />
JSONObject json = jParser.getJSONFromUrl(url);<br />
<br />
try {<br />
// Getting Array of results<br />
results = json.getJSONArray(TAG_RESULTS);<br />
<br />
Toast.makeText(getApplication(),<br />
"Number of results : " + results.length(),<br />
Toast.LENGTH_LONG).show();<br />
<br />
for (int i = 0; i < results.length(); i++) {<br />
JSONObject r = results.getJSONObject(i);<br />
<br />
// geometry and location is again JSON Object<br />
JSONObject geometry = r.getJSONObject(TAG_GEOMETRY);<br />
<br />
JSONObject viewport = geometry.getJSONObject(TAG_VIEWPORT);<br />
<br />
JSONObject northest = viewport.getJSONObject(TAG_NORTHEAST);<br />
<br />
String lat = northest.getString(TAG_LAT);<br />
String lng = northest.getString(TAG_LNG);<br />
<br />
tvlat.setText(lat);<br />
tvlng.setText(lng);<br />
}<br />
<br />
} catch (JSONException e) {<br />
e.printStackTrace();<br />
}<br />
<br />
<br />
<b>JSONParser.java</b><br />
<br />
public class JSONParser {<br />
<br />
static InputStream is = null;<br />
static JSONObject jObj = null;<br />
static String json = "";<br />
<br />
// constructor<br />
public JSONParser() {<br />
<br />
}<br />
<br />
public JSONObject getJSONFromUrl(String url) {<br />
<br />
// Making HTTP request<br />
try {<br />
// defaultHttpClient<br />
DefaultHttpClient httpClient = new DefaultHttpClient();<br />
HttpPost httpPost = new HttpPost(url);<br />
<br />
HttpResponse httpResponse = httpClient.execute(httpPost);<br />
HttpEntity httpEntity = httpResponse.getEntity();<br />
is = httpEntity.getContent(); <br />
<br />
} catch (UnsupportedEncodingException e) {<br />
e.printStackTrace();<br />
} catch (ClientProtocolException e) {<br />
e.printStackTrace();<br />
} catch (IOException e) {<br />
e.printStackTrace();<br />
}<br />
<br />
try {<br />
BufferedReader reader = new BufferedReader(new InputStreamReader(<br />
is, "iso-8859-1"), 8);<br />
StringBuilder sb = new StringBuilder();<br />
String line = null;<br />
while ((line = reader.readLine()) != null) {<br />
sb.append(line + "\n");<br />
}<br />
is.close();<br />
json = sb.toString();<br />
} catch (Exception e) {<br />
Log.e("Buffer Error", "Error converting result " + e.toString());<br />
}<br />
<br />
// try parse the string to a JSON object<br />
try {<br />
jObj = new JSONObject(json);<br />
} catch (JSONException e) {<br />
Log.e("JSON Parser", "Error parsing data " + e.toString());<br />
}<br />
<br />
// return JSON String<br />
return jObj;<br />
<br />
}<br />
}<br />
<br />
<b><br /></b>
<b> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <br /> <uses-permission android:name="android.permission.INTERNET" /><br /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/></b><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8_K2JToNUf5LEGjPxo1_Hbj0JdYPkcveWer9W1VppoiWTYO8o1ulpJB39vNk81GugTMDRjLNdQTcize5DaXYFtqcfcNlj9SM_TaIrjMtfFRllLWdUGym7vhcsNCy6dPJv4_r9FLG3EpE/s1600/device-2013-03-22-115418.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8_K2JToNUf5LEGjPxo1_Hbj0JdYPkcveWer9W1VppoiWTYO8o1ulpJB39vNk81GugTMDRjLNdQTcize5DaXYFtqcfcNlj9SM_TaIrjMtfFRllLWdUGym7vhcsNCy6dPJv4_r9FLG3EpE/s1600/device-2013-03-22-115418.png" height="320" width="213" /></a></div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-879441915630990992.post-25245892881250758782013-03-13T23:24:00.000-07:002016-02-14T06:06:50.880-08:00Android Interview Questions and Answer <div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<meta name="keywords" content="android, 1, null, string, upload, buffersize, //, server, <xml, tutorial, video server, upload video, android tutorial, upload video server, video, programmatically, lineend, 0, post, <linearlayout, bytesread, encoding"utf-8"> <linearlayout, 2, boundary, logemediaplayer, mapview, error, â–º , public, bytesavailable,">
<![endif]-->
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style>
<![endif]-->
<br />
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: 5.0pt; mso-outline-level: 3;">
<b><span style="color: red; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">1. Define Android?</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"></span></div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: 5.0pt; mso-outline-level: 3;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?blogID=879441915630990992" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<b><span style="color: black; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Android is software
stack for mobile devices that has middleware, operating system and specific key
applications. The application must be implemented in its own process and Dalvik
Virtual Machine interface. DVM device is used to effectively run several
virtual machines. The byte code of java language is executed by DVM that is
converted to .dex format files.</span></b><b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
<br />
</span></b><b><span style="color: red; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">2. Define Activity?</span></b><b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
</span></b><b><span style="font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Activity is nothing but
application’s single screen that assists java code.<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">3. Define intent?</span><span style="color: #5c5a52;"><br />
</span>Intent is a class that depicts what caller has to do. Intent is send to
intent resolver of Android by the caller which finds appropriate activity for
intent. For example: intent is opening PDF doc and the perfect activity for
intent is apps of Adobe Reader.<br />
<span style="color: #5c5a52;"><br />
</span><span style="color: red;">4. Define resource?</span><span style="color: #5c5a52;"><br />
</span>Resource is nothing but user defined XML, JSON or bitmap that is
inserted in application build process which is later loaded from code.</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7vfRzQ6_2gzhPmmpPIKnnxNlEvMUvuN8-GPBhqq3yuszq7rB0IZbhGqQqb5txe4l8NetJPhyphenhyphen2h59WQP0FKLrn6FKVctPhf4Urqvlmd9bxubpIIyWS_ky2FStukJy97X4Nux_TdoOvzlk/s1600/photo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7vfRzQ6_2gzhPmmpPIKnnxNlEvMUvuN8-GPBhqq3yuszq7rB0IZbhGqQqb5txe4l8NetJPhyphenhyphen2h59WQP0FKLrn6FKVctPhf4Urqvlmd9bxubpIIyWS_ky2FStukJy97X4Nux_TdoOvzlk/s1600/photo.jpg" /></a></div>
<b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
</span></b><b><span style="color: red; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">5. Does Android assist profile
of Bluetooth serial port?</span></b><b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
</span></b><b><span style="font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Yes</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><br />
<br />
</span><b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
<br />
</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"></span></div>
<div align="center" class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: center;">
</div>
<div class="MsoNormal" style="background: white; line-height: 15.0pt; margin-bottom: 5.0pt; mso-outline-level: 3;">
<b><span style="color: red; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">6. Is it possible to start
an application on powerup?</span></b><b><span style="color: #5c5a52; font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";"><br />
</span></b><b><span style="font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Yes<span style="color: #5c5a52;"><br />
<br />
<br />
</span><span style="color: red;">7. Define APK format?</span><span style="color: #5c5a52;"><br />
</span>APK file is compacted AndroidManifest.xml file that has .apk extension.
Resource files, Application code and many other files are present in this
format and are compressed to single file which has .apk extension.<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">8. Explain translation in Android?</span><span style="color: #5c5a52;"><br />
</span>The data of one language can be changed to other language by Google
translator by making use of XMPP for data transmission. You can type English
message and choose the language that is easily understood by your country
people to reach message to them.<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">9. On which virtual machine Android runs?</span><span style="color: #5c5a52;"><br />
</span>Dalvik virtual machine<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">10. What is the latest version in android?</span><span style="color: #5c5a52;"><br />
</span>Android 4.2(</span></b><b><span style="font-family: "Arial","sans-serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Jelly Bean)<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">12. Give the new Android platform for mobile
phones?</span><span style="color: #5c5a52;"><br />
</span>Android 4.0 and the name given to this version is Ice-cream Sandwich.
The versions that came before this are given below:<br />
• 3. X.X Honeycomb<br />
• 2.3. X Gingerbread<br />
• 2.2 Froyo<br />
• 2.0/2.1 Éclair<br />
• 1.6 Donut<br />
• 1.5 Cupcake<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">13. Give the languages that are supported by
Android operating system for developing applications?</span><span style="color: #5c5a52;"><br />
</span>It supports all the languages that are written using java code.<span style="color: #5c5a52;"><br />
<br />
<br />
</span><span style="color: red;">14. In what ways data can be stored in Android?</span><span style="color: #5c5a52;"><br />
</span>• Internal storage<br />
• Network connection<br />
• Shared preferences<br />
• Sqlite database<br />
• External storage<span style="color: #5c5a52;"><br />
<br />
</span><span style="color: red;">15. What are user interface types?</span><span style="color: #5c5a52;"><br />
</span>• Notifications<br />
• Views<span style="color: #5c5a52;"><br />
<br />
<br />
</span><span style="color: red;">16. Give notification types in Android?</span><span style="color: #5c5a52;"><br />
</span><span style="color: black; mso-themecolor: text1;">• Dialog notification<br />
• Status bar notification<br />
• Tost notification</span></span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"></span></div>
<div class="MsoNormal">
<br /></div>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-879441915630990992.post-57048805516071424322013-03-12T23:12:00.001-07:002016-02-14T06:07:01.068-08:00Android Phone call history/log programmatically<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<br />
<b>activity_main.xml</b><br />
<br />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
xmlns:tools="http://schemas.android.com/tools"<br />
android:layout_width="match_parent"<br />
android:layout_height="match_parent"<br />
tools:context=".MainActivity" ><br />
<br />
<TextView<br />
android:id="@+id/call"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:layout_centerHorizontal="true"<br />
android:layout_centerVertical="true"<br />
android:text="@string/hello_world" /><br />
<br />
</RelativeLayout><br />
<br />
<b>MainActivity.java</b><br />
<br />
public class MainActivity extends Activity {<br />
<br />
private static final int MISSED_CALL_TYPE = 0;<br />
private TextView txtcall;<br />
<br />
@Override<br />
protected void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.activity_main);<br />
<br />
txtcall = (TextView) findViewById(R.id.call);<br />
<br />
StringBuffer sb = new StringBuffer();<br />
Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,<br />
null, null, null);<br />
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);<br />
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);<br />
int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);<br />
int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);<br />
sb.append("Call Details :");<br />
while (managedCursor.moveToNext()) {<br />
String phNumber = managedCursor.getString(number);<br />
String callType = managedCursor.getString(type);<br />
String callDate = managedCursor.getString(date);<br />
Date callDayTime = new Date(Long.valueOf(callDate));<br />
String callDuration = managedCursor.getString(duration);<br />
String dir = null;<br />
int dircode = Integer.parseInt(callType);<br />
switch (dircode) {<br />
<br />
case CallLog.Calls.OUTGOING_TYPE:<br />
dir = "OUTGOING";<br />
break;<br />
<br />
case CallLog.Calls.INCOMING_TYPE:<br />
dir = "INCOMING";<br />
break;<br />
<br />
case CallLog.Calls.MISSED_TYPE:<br />
dir = "MISSED";<br />
break;<br />
}<br />
sb.append("\nPhone Number:--- " + phNumber + " \nCall Type:--- "<br />
+ dir + " \nCall Date:--- " + callDayTime<br />
+ " \nCall duration in sec :--- " + callDuration);<br />
sb.append("\n----------------------------------");<br />
}<br />
managedCursor.close();<br />
txtcall.setText(sb);<br />
}<br />
<br />
@Override<br />
public boolean onCreateOptionsMenu(Menu menu) {<br />
// Inflate the menu; this adds items to the action bar if it is present.<br />
getMenuInflater().inflate(R.menu.activity_main, menu);<br />
return true;<br />
}<br />
<br />
}<b> </b><br />
<br />
<b> <uses-permission android:name="android.permission.READ_CONTACTS"/><br /> <uses-permission android:name="android.permission.READ_LOGS"/></b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYVGbKE-pRjqnmAkTvQdH41a6wmdf_9voY2a1tZEloF1a_fBMvU5SmEq2JKRU3Zm1-TGH49SriuB2c2AduSLhXQcaAQJurbqxovkuWrgfNAf06F8_oWArvyo_ZvrWxeolmyvhW7SDMAp8/s1600/device-2013-03-13-114105.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYVGbKE-pRjqnmAkTvQdH41a6wmdf_9voY2a1tZEloF1a_fBMvU5SmEq2JKRU3Zm1-TGH49SriuB2c2AduSLhXQcaAQJurbqxovkuWrgfNAf06F8_oWArvyo_ZvrWxeolmyvhW7SDMAp8/s1600/device-2013-03-13-114105.png" height="320" width="213" /></a></div>
<br />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-879441915630990992.post-74141714352287001982012-12-21T04:46:00.001-08:002016-02-14T06:07:14.590-08:00Android Turn ON wifi programmatically<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<meta name="keywords" content="android, programmatically, wifi, 1, wifi programmatically, turn, import, turn wifi programmatically, turn wifi, uses-permission, android tutorial, programmatically android, wifimanager, post, toast, tutorial, gravity, version"10", public, xml, different, 2, , show, upload, , file, mapview">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: #f3f6f2; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b>Android Turn ON wifi programmatically</b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span style="color: #38761d;"><b>C</b></span>oding for Enable WIFI programmatically.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div style="background-color: #f3f6f2; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b>Activity.class</b></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
import android.app.Activity;</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
import android.content.Context;</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
import android.net.wifi.WifiManager;</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
import android.os.Bundle;</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
import android.widget.TextView;</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
public class WifiEnableActivity extends Activity {</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
/** Called when the activity is first created. */</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
private WifiManager wifiManager; </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
@Override</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
public void onCreate(Bundle savedInstanceState) {</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
super.onCreate(savedInstanceState);</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
setContentView(R.layout.main);</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
TextView text = (TextView)findViewById(R.id.<span style="color: #38761d;">txtWiFi</span>);</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
wifiManager.setWifiEnabled(true); </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
if(wifiManager.isWifiEnabled()){</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
text.setText("Wifi State Enabled");</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
}</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
}</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
}</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div style="background-color: #f3f6f2; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<b>Then some permission and user feature required in manifest file.</b></div>
<div style="background-color: #f3f6f2; font-family: Arial,Tahoma,Helvetica,FreeSans,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"></uses-permission> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-feature android:name="android.hardware.wifi.direct" /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-permission android:name="android.permission.INTERNET" /> </div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: black; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
</div>
<a href="https://github.com/niravranpara/wifiOn" target="_blank">Download Source Code </a></div>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-38137804846709387742012-12-20T04:21:00.000-08:002016-02-14T06:07:18.339-08:00Android Toast notification show Different Gravity<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<meta name="keywords" content="android, toast, 1, 0, show different gravity, show different, gravity, different gravity, different, show, programmatically, notification, tutorial, notification show, 0 tshow, toastmaketextmainactivitythis, public, t, tshow, toastlength_long, post, wifi">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: #0c0c0c; display: inline !important; float: none; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">Toast notify we can show in different gravity like "TOP", "RIGHT", "LEFT", "BOTTOM",etc.<span class="Apple-converted-space"></span></span><br />
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: #0c0c0c; display: inline !important; float: none; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span class="Apple-converted-space"><br /></span></span>
<span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #f3f6f2; color: #0c0c0c; display: inline !important; float: none; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span class="Apple-converted-space">public class MainActivity extends Activity {<br /><br /> @Override<br /> public void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.activity_main);<br /> <br /> <br /> Toast t = Toast.makeText(MainActivity.this, "TOP | RIGHT", Toast.LENGTH_LONG);<br /> t.setGravity(Gravity.TOP|Gravity.RIGHT, 0, 0); <br /> t.show();<br /> <br /> t = Toast.makeText(MainActivity.this, "CENTER", Toast.LENGTH_LONG);<br /> t.setGravity(Gravity.CENTER, 0, 0);<br /> t.show();<br /> <br /> t = Toast.makeText(MainActivity.this, "BOTTOM | LEFT", Toast.LENGTH_LONG);<br /> t.setGravity(Gravity.BOTTOM|Gravity.LEFT, 0, 0);<br /> t.show();<br /> <br /> t = Toast.makeText(MainActivity.this, "CENTER | LEFT", Toast.LENGTH_LONG);<br /> t.setGravity(Gravity.CENTER|Gravity.LEFT, 0, 0);<br /> t.show();<br /> <br /> }<br /> <br /> @Override<br /> public boolean onCreateOptionsMenu(Menu menu) {<br /> getMenuInflater().inflate(R.menu.activity_main, menu);<br /> return true;<br /> }<br />}</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigflDUvIEkWSx7_umDNO_C-bFyOuLfLD5Th-DyAADPHy6MOt3FyYv4muY9bXZbTn1bmMFuXKSLCn8IOPNWWlR7Pe0yrlksuKzOgTioPKOuBhhrQvvqSSI0l7mwIplGEd5HG1oj63lHgLg/s1600/toast.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigflDUvIEkWSx7_umDNO_C-bFyOuLfLD5Th-DyAADPHy6MOt3FyYv4muY9bXZbTn1bmMFuXKSLCn8IOPNWWlR7Pe0yrlksuKzOgTioPKOuBhhrQvvqSSI0l7mwIplGEd5HG1oj63lHgLg/s1600/toast.png" height="320" width="213" /></a></div>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-18107067097869098562012-11-26T22:47:00.004-08:002016-02-14T06:07:22.701-08:00Android Capture photo using camera<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<meta name="keywords" content="android, 1, camera, photo, capture photo, photo using camera, photo using, capture, using camera, android tutorial, using, public, linearlayout, tutorial, post, xml, programmatically, activity_mainxml, mapview, 2, wifi, upload, toast, camera_request, bitmap">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b>activity_main.xml</b><br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:layout_width="fill_parent"<br />
android:layout_height="fill_parent"<br />
android:orientation="vertical" ><br />
<br />
<Button<br />
android:id="@+id/button1"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:text="photo" ><br />
</Button><br />
<br />
<ImageView<br />
android:id="@+id/imageView1"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"<br />
android:src="@drawable/ic_launcher" ><br />
</ImageView><br />
<br />
</LinearLayout><br />
<br />
<b>MainActivity.java</b><br />
<br />
public class MainActivity extends Activity {<br />
private static final int CAMERA_REQUEST = 1888; <br />
private ImageView imageView;<br />
<br />
@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.activity_main);<br />
this.imageView = (ImageView)this.findViewById(R.id.imageView1);<br />
Button photoButton = (Button) this.findViewById(R.id.button1);<br />
photoButton.setOnClickListener(new View.OnClickListener() {<br />
<br />
@Override<br />
public void onClick(View v) {<br />
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); <br />
startActivityForResult(cameraIntent, CAMERA_REQUEST); <br />
}<br />
});<br />
}<br />
<br />
protected void onActivityResult(int requestCode, int resultCode, Intent data) { <br />
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { <br />
Bitmap photo = (Bitmap) data.getExtras().get("data"); <br />
imageView.setImageBitmap(photo);<br />
} <br />
} <br />
}<br />
<br />
<b>AndroidManifest.xml</b><br />
<br />
<uses-feature android:name="android.hardware.camera"></uses-feature></div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-66641920832396535422012-11-01T23:45:00.003-07:002013-04-05T14:00:00.995-07:00Android Google Mapview <script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div dir="ltr" style="text-align: left;" trbidi="on">
<b>main.xml</b><br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:orientation="vertical"<br />
android:layout_width="fill_parent"<br />
android:layout_height="fill_parent"><br />
<br />
<br />
<TextView android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:text="Waiting for location..."<br />
android:id="@+id/lblLocationInfo"/><br />
<!-- <1> --><br />
<br />
<br />
<br />
<com.google.android.maps.MapView android:id="@+id/mapview"<br />
android:apiKey="0dv9akiSW0I8Vvu5Ht_ScUSAEA6tngHm7Sta1ZA" <br />
android:enabled="true"<br />
<br />
android:clickable="true" <br />
android:focusableInTouchMode="true"<br />
android:layout_width="fill_parent" <br />
android:layout_height="fill_parent"<br />
/> <br />
<br />
<br />
</LinearLayout><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwM-xQe3tV679XVKBMhDLQNjHsrPYQSVUA2w4TCto-CWgyJFgnlOni4h2JgrhKn0b-5G0L7tMrF_XcxncEMt_Xxc5XoRGUu1NmNeRFcOmfM0ugPeLz45JVyDv1mAvpxR-sYFCtTeVgFLo/s1600/photo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwM-xQe3tV679XVKBMhDLQNjHsrPYQSVUA2w4TCto-CWgyJFgnlOni4h2JgrhKn0b-5G0L7tMrF_XcxncEMt_Xxc5XoRGUu1NmNeRFcOmfM0ugPeLz45JVyDv1mAvpxR-sYFCtTeVgFLo/s1600/photo.jpg" /></a></div>
<br />
<br />
<b>map.java</b><br />
<br />
public class map extends MapActivity implements LocationListener { //<1><br />
<br />
private static final String TAG = "LocationActivity";<br />
<br />
LocationManager locationManager; //<2><br />
Geocoder geocoder; //<3><br />
TextView locationText;<br />
MapView map; <br />
MapController mapController; //<4><br />
<br />
<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.main);<br />
<br />
locationText = (TextView)this.findViewById(R.id.lblLocationInfo);<br />
map = (MapView)this.findViewById(R.id.mapview);<br />
map.setBuiltInZoomControls(true);<br />
<br />
mapController = map.getController(); //<4><br />
mapController.setZoom(16);<br />
<br />
locationManager = (LocationManager)this.getSystemService(LOCATION_SERVICE); //<2><br />
<br />
geocoder = new Geocoder(this); //<3><br />
<br />
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); //<5><br />
if (location != null) {<br />
Log.d(TAG, location.toString());<br />
this.onLocationChanged(location); //<6><br />
}<br />
}<br />
<br />
<br />
protected void onResume() {<br />
super.onResume();<br />
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10, this); //<7><br />
}<br />
<br />
<br />
protected void onPause() {<br />
super.onPause();<br />
locationManager.removeUpdates(this); //<8><br />
}<br />
<br />
<br />
public void onLocationChanged(Location location) { //<9><br />
Log.d(TAG, "onLocationChanged with location " + location.toString());<br />
String text = String.format("Lat:\t %f\nLong:\t %f\nAlt:\t %f\nBearing:\t %f", location.getLatitude(), <br />
location.getLongitude(), location.getAltitude(), location.getBearing());<br />
this.locationText.setText(text);<br />
<br />
try {<br />
List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 10); //<10><br />
for (Address address : addresses) {<br />
this.locationText.append("\n" + address.getAddressLine(0));<br />
}<br />
<br />
int latitude = (int)(location.getLatitude() * 1000000);<br />
int longitude = (int)(location.getLongitude() * 1000000);<br />
<br />
GeoPoint point = new GeoPoint(latitude,longitude);<br />
mapController.animateTo(point); //<11><br />
<br />
} catch (IOException e) {<br />
Log.e("LocateMe", "Could not get Geocoder data", e);<br />
}<br />
}<br />
<br />
<br />
protected boolean isRouteDisplayed() {<br />
// TODO Auto-generated method stub<br />
return false;<br />
}<br />
<br />
<br />
public void onProviderDisabled(String provider) {<br />
// TODO Auto-generated method stub<br />
<br />
}<br />
<br />
<br />
public void onProviderEnabled(String provider) {<br />
// TODO Auto-generated method stub<br />
<br />
}<br />
<br />
<br />
public void onStatusChanged(String provider, int status, Bundle extras) {<br />
// TODO Auto-generated method stub<br />
<br />
}<br />
<br />
}<br />
<br />
<b>AndroidManifest.xml</b><br />
<br />
<uses-permission android:name="android.permission.INTERNET" /><br />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <br />
<br />
<uses-library android:name="com.google.android.maps" /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-879441915630990992.post-30731683683970953722012-11-01T23:22:00.000-07:002016-02-14T06:07:37.728-08:00Android Upload Video in server <script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35073969-1']);
_gaq.push(['_setDomainName', 'niravranpara.blogspot.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<b>main.xml</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<?xml version="1.0" encoding="utf-8"?><br />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br />
android:orientation="vertical"<br />
android:layout_width="fill_parent"<br />
android:layout_height="fill_parent"<br />
><br />
<TextView <br />
android:layout_width="fill_parent" <br />
android:layout_height="wrap_content" <br />
android:text=""</div>
<div style="text-align: left;">
android:id="@+id/tv"</div>
<div style="text-align: left;">
/><br />
<TextView<br />
android:layout_width="fill_parent"<br />
android:layout_height="wrap_content"<br />
android:text="@string/hello"<br />
/><br />
<Button android:text="Browse gallery"<br />
android:id="@+id/Button01"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"><br />
</Button><br />
<ImageView android:id="@+id/ImageView01"<br />
android:layout_width="wrap_content"<br />
android:layout_height="wrap_content"><br />
</ImageView><br />
</LinearLayout><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwK5uxlQE6ewTeCFQzlm725JHqnnON9B0Aon8ND-6GCCIpSI-6rBYHgg5I5x0MpRGV1v8vUBrurvzOJEX5rdDbzP1ajrtfm-rRmZK1xdynjrIwNoj4PDgPciS9u79yqwnJUnGq39QNxkM/s1600/photo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwK5uxlQE6ewTeCFQzlm725JHqnnON9B0Aon8ND-6GCCIpSI-6rBYHgg5I5x0MpRGV1v8vUBrurvzOJEX5rdDbzP1ajrtfm-rRmZK1xdynjrIwNoj4PDgPciS9u79yqwnJUnGq39QNxkM/s1600/photo.jpg" /></a></div>
<br />
<b>uploadfile.java</b> <br />
<br />
public class uploadfile extends Activity {<br />
TextView tv = null;<br />
<br />
@Override<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.main);<br />
tv = (TextView) findViewById(R.id.tv);<br />
doFileUpload();<br />
}<br />
<br />
private void doFileUpload(){<br />
<br />
HttpURLConnection conn = null;<br />
DataOutputStream dos = null;<br />
DataInputStream inStream = null; <br />
<br />
<br />
String exsistingFileName = "/sdcard/six.3gp";<br />
// Is this the place are you doing something wrong.<br />
<br />
String lineEnd = "\r\n";<br />
String twoHyphens = "--";<br />
String boundary = "*****";<br />
<br />
<br />
int bytesRead, bytesAvailable, bufferSize;<br />
<br />
byte[] buffer;<br />
<br />
int maxBufferSize = 1*1024*1024;<br />
<br />
String urlString = "http://192.168.1.5/upload.php";<br />
<br />
<br />
<br />
try<br />
{<br />
<br />
<br />
Log.e("MediaPlayer","Inside second Method");<br />
<br />
FileInputStream fileInputStream = new FileInputStream(new File(exsistingFileName) );<br />
<br />
<br />
<br />
URL url = new URL(urlString);<br />
<br />
conn = (HttpURLConnection) url.openConnection();<br />
<br />
conn.setDoInput(true);<br />
<br />
// Allow Outputs<br />
conn.setDoOutput(true);<br />
<br />
// Don't use a cached copy.<br />
conn.setUseCaches(false);<br />
<br />
// Use a post method.<br />
conn.setRequestMethod("POST");<br />
<br />
conn.setRequestProperty("Connection", "Keep-Alive");<br />
<br />
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);<br />
<br />
<br />
dos = new DataOutputStream( conn.getOutputStream() );<br />
<br />
dos.writeBytes(twoHyphens + boundary + lineEnd);<br />
dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + exsistingFileName +"\"" + lineEnd);<br />
dos.writeBytes(lineEnd);<br />
<br />
Log.e("MediaPlayer","Headers are written");<br />
<br />
<br />
<br />
bytesAvailable = fileInputStream.available();<br />
bufferSize = Math.min(bytesAvailable, maxBufferSize);<br />
buffer = new byte[bufferSize];<br />
<br />
<br />
<br />
bytesRead = fileInputStream.read(buffer, 0, bufferSize);<br />
<br />
while (bytesRead > 0)<br />
{<br />
dos.write(buffer, 0, bufferSize);<br />
bytesAvailable = fileInputStream.available();<br />
bufferSize = Math.min(bytesAvailable, maxBufferSize);<br />
bytesRead = fileInputStream.read(buffer, 0, bufferSize);<br />
}<br />
<br />
<br />
<br />
dos.writeBytes(lineEnd);<br />
<br />
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);<br />
<br />
BufferedReader in = new BufferedReader(<br />
new InputStreamReader(<br />
conn.getInputStream()));<br />
String inputLine;<br />
<br />
while ((inputLine = in.readLine()) != null) <br />
tv.append(inputLine);<br />
<br />
<br />
<br />
<br />
// close streams<br />
Log.e("MediaPlayer","File is written");<br />
fileInputStream.close();<br />
dos.flush();<br />
dos.close();<br />
<br />
<br />
}<br />
catch (MalformedURLException ex)<br />
{<br />
Log.e("MediaPlayer", "error: " + ex.getMessage(), ex);<br />
}<br />
<br />
catch (IOException ioe)<br />
{<br />
Log.e("MediaPlayer", "error: " + ioe.getMessage(), ioe);<br />
}<br />
<br />
<br />
//------------------ read the SERVER RESPONSE<br />
<br />
<br />
try {<br />
inStream = new DataInputStream ( conn.getInputStream() );<br />
String str;<br />
<br />
while (( str = inStream.readLine()) != null)<br />
{<br />
Log.e("MediaPlayer","Server Response"+str);<br />
}<br />
/*while((str = inStream.readLine()) !=null ){<br />
<br />
}*/<br />
inStream.close();<br />
<br />
}<br />
catch (IOException ioex){<br />
Log.e("MediaPlayer", "error: " + ioex.getMessage(), ioex);<br />
}<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
<b>AndroidManifest.xml</b><br />
<br />
<uses-permission android:name="android.permission.INTERNET" /><b> </b><br />
<br />
<b>upload.php</b><br />
<br />
<?php<br />
<br />
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "./".$_FILES["uploadedfile"]["name"]);<br />
<br />
?><br />
<br /></div>
</div>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Large mobile banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-7883603343878956"
data-ad-slot="3593756820"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>Unknownnoreply@blogger.com6