tag:blogger.com,1999:blog-57400272069766387552024-03-04T22:17:39.143-08:00Developer Dot AndroidLearn about the Android Development and how it can be used to create mobile and non-mobile applications.This website give full tutorials for develop android application and it is absolutely free.Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-5740027206976638755.post-71332927504298993462012-04-18T02:16:00.001-07:002012-04-18T02:19:03.500-07:00Custom Toast<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><span style="color: lime; font-size: large;"><b>custom_toast_layout.xml</b></span><br />
<br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/picture_frame"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:src="@drawable/inbox" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="Toast text here"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</pre><br />
<br />
<b><span style="color: lime; font-size: large;">main.xml</span></b><br />
<br />
<br />
</div><pre class="brush: csharp"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#454545"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click here to see custom Toast" />
</RelativeLayout></pre><br />
<span style="color: lime; font-size: large;"><b>In java File</b></span><br />
<br />
<br />
</div><pre class="brush: csharp">Button mButton1 = (Button) findViewById(R.id.button1);
mButton1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast_layout,
(ViewGroup) findViewById(R.id.root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Message Sent Succesfully !!");
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.BOTTOM, 10, 80);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
});</pre><br />
</div><span style="color: lime; font-size: large;"><b>Multiple Toast </b></span><br />
<span style="color: lime; font-size: large;"><b><br />
</b></span><br />
<span style="color: lime; font-size: large;"><b><br />
</b></span></div><pre class="brush: csharp">Toast m_currentToast;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button mButton = (Button) findViewById(R.id.button);
mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
showToast("5");
showToast("4");
showToast("3");
showToast("2");
showToast("1");
showToast("Go go go...");
}
});
}
void showToast(String text) {
if (m_currentToast != null) {
m_currentToast.cancel();
}
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast_layout,
(ViewGroup) findViewById(R.id.root));
TextView text1 = (TextView) layout.findViewById(R.id.text);
text1.setText(text);
m_currentToast = new Toast(getApplicationContext());
m_currentToast.setDuration(Toast.LENGTH_SHORT);
m_currentToast.setView(layout);
m_currentToast.setGravity(Gravity.TOP, 10, 180);
m_currentToast.show();
}</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-23102234359960573662012-04-07T22:43:00.001-07:002012-04-07T23:22:14.331-07:00Secret Codes For Android Mobile Phones<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<br />
<br />
<span style="color: lime; font-family: Times, 'Times New Roman', serif; font-size: large;">1. Complete Information About your Phone</span><br />
<br />
<span style="color: red; font-size: large;">*#*#4636#*#*</span><br />
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/PRSQiGSP23A?feature=player_embedded' frameborder='0'></iframe><br />
This code can be used to get some interesting information about your phone and battery.<br />
Usage statistics<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">2. Factory data reset</span><br />
<br />
<span style="color: red; font-size: large;">*#*#7780#*#*</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOTrmeTJlfm1m1uQs24SXBkujFnFR-l1CFLwnHUlroasV5epUhHIbrJTGGxuTh36uuy6m-8L8gZfpXlvqCoYQqrMULG_moC_BAuRiXRz2G17uxpZXOP0G816q239M-dLNPRlHoObX7sOk/s1600/reset+factory+data.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOTrmeTJlfm1m1uQs24SXBkujFnFR-l1CFLwnHUlroasV5epUhHIbrJTGGxuTh36uuy6m-8L8gZfpXlvqCoYQqrMULG_moC_BAuRiXRz2G17uxpZXOP0G816q239M-dLNPRlHoObX7sOk/s1600/reset+factory+data.png" /></a><br />
This code can be used for a factory data reset. It'll remove following things:<br />
Google account settings stored in your phone<br />
System and application data and settings<br />
Downloaded applications<br />
<br />
It'll NOT remove:<br />
Current system software and bundled application<br />
SD card files e.g. photos, music files, etc.<br />
Note: Once you give this code, you get a prompt screen asking you to click on "Reset phone" button. So you get a chance to cancel your operation.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">3. Format Android Phone</span><br />
<span style="color: red; font-size: large;">*2767*3855#</span><br />
<br />
Think before you give this code. This code is used for factory format. It'll remove all files and settings including the internal memory storage. It'll also reinstall the phone firmware.<br />
<br />
Note: Once you give this code, there is no way to cancel the operation unless you remove the battery from the phone. So think twice before giving this code.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">4. Phone Camera Update</span><br />
<span style="color: red; font-size: large;">*#*#34971539#*#*</span><br />
<br />
This code is used to get information about phone camera. It shows following 4 menus:<br />
Update camera firmware in image (Don't try this option)<br />
Update camera firmware in SD card<br />
Get camera firmware version<br />
Get firmware update count<div><br />
<span style="color: red;">WARNING</span>: Never use the first option otherwise your phone camera will stop working and you'll need to take your phone to service center to reinstall camera firmware.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">5. End Call/Power</span><br />
<span style="color: red; font-size: large;">*#*#7594#*#*</span><br />
<br />
This one is my favorite one. This code can be used to change the "End Call / Power" button action in your phone. Be default, if you long press the button, it shows a screen asking you to select any option from Silent mode, AirPlane mode and Power off.<br />
<br />
You can change this action using this code. You can enable direct power off on this button so you don't need to waste your time in selecting the option.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">6. File Copy for Creating Backup</span><br />
<br />
<span style="color: red; font-size: large;">*#*#273283*255*663282*#*#*</span><br />
<br />
This code opens a File copy screen where you can backup your media files e.g. Images, Sound, Video and Voice memo.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">7. Service Mode</span><br />
<br />
<span style="color: red; font-size: large;">*#*#197328640#*#*</span><br />
This code can be used to enter into Service mode. You can run various tests and change settings in the service mode.<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">8. WLAN, GPS and Bluetooth Test Codes:</span><br />
<br />
<span style="color: red; font-size: large;">*#*#232339#*#*</span> OR <span style="color: red; font-size: large;">*#*#526#*#*</span> OR <span style="color: red; font-size: large;">*#*#528#*#*</span> - WLAN test (Use "Menu" button to start various tests)<br />
<br />
<span style="color: red; font-size: large;">*#*#232338#*#</span><span style="color: red; font-size: large;">*</span> - Shows WiFi MAC address<br />
<br />
<span style="color: red; font-size: large;">*#*#1472365#*#*</span> - GPS test<br />
<br />
<span style="color: red; font-size: large;">*#*#1575#*#*</span> - Another GPS test<br />
<br />
<span style="color: red; font-size: large;">*#*#232331#*#</span><span style="color: red; font-size: large;">*</span> - Bluetooth test<br />
<br />
<span style="color: red; font-size: large;">*#*#232337#*#*</span> - Shows Bluetooth device address<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">9. Codes to get Firmware version information:</span><br />
<br />
<span style="color: red; font-size: large;">*#*#4986*2650468#*#*</span> - PDA, Phone, H/W, RFCallDate<br />
<br />
<span style="color: red; font-size: large;">*#*#1234#*#*</span> - PDA and Phone<br />
<br />
<span style="color: red; font-size: large;">*#*#1111#*#*</span> - FTA SW Version<br />
<br />
<span style="color: red; font-size: large;">*#*#2222#*#*</span> - FTA HW Version<br />
<br />
<span style="color: red; font-size: large;">*#*#44336#*#* </span>- PDA, Phone, CSC, Build Time, Changelist number<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-size: large;">10. Codes to launch various Factory Tests:</span><br />
<span style="color: red; font-size: large;"><br />
*#*#0283#*#*</span> - Packet Loopback<br />
<br />
<span style="color: red; font-size: large;">*#*#0*#*#*</span> - LCD test<br />
<br />
<span style="color: red; font-size: large;">*#*#0673#*#*</span> OR <span style="color: red; font-size: large;">*#*#0289#*#*</span> - Melody test<br />
<br />
<span style="color: red; font-size: large;">*#*#0842#*#*</span> - Device test (Vibration test and BackLight test)<br />
<br />
<span style="color: red; font-size: large;">*#*#2663#*#*</span> - Touch screen version<br />
<br />
<span style="color: red; font-size: large;">*#*#2664#*#*</span> - Touch screen test<br />
<br />
<span style="color: red; font-size: large;">*#*#0588#*#*</span> - Proximity sensor test<br />
<br />
<span style="color: red; font-size: large;">*#*#3264#*#*</span> - RAM version</div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-47976843380390458182012-04-07T21:37:00.002-07:002012-04-07T21:40:19.877-07:00Standard Android Button with a different color<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/Pyv4kuDZDVM?feature=player_embedded' frameborder='0'></iframe></div><br />
<br />
Add this file into drawable folder in res folder </div><div><br />
</div><span style="color: lime; font-size: large;"><b>red_button.xml</b></span><br />
<div><br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#FFFFFF"
android:endColor="#FFEEEE"
android:angle="270" />
<stroke
android:width="2dp"
android:color="#454545" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="true" >
<shape>
<gradient
android:endColor="#FF0000"
android:startColor="#AA0000"
android:angle="270" />
<stroke
android:width="2dp"
android:color="#FFFFFF" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:endColor="#FF0000"
android:startColor="#AA0000"
android:angle="270" />
<stroke
android:width="2dp"
android:color="#454545" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
</pre><div><br />
And set background to button like<br />
<br />
</div></div><pre class="brush: csharp"><Button android:text="Click Me !" android:id="@+id/button1"
android:background="@drawable/red_button" android:layout_margin="10dp"
android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</pre><br />
<br />
That's it !!<br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com1tag:blogger.com,1999:blog-5740027206976638755.post-50218111356613924782012-03-30T09:42:00.000-07:002012-03-30T09:42:20.065-07:00Android 9 Patch Image Tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Arial, Helvetica, sans-serif;"><i style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">This tutorial describes what Android 9 patch images are, how to make them, and how to use 9 Patch images in Android applications.</i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="font-size: medium;"><span style="color: lime;">What is a 9 Patch Image?</span></span></span><br />
<br />
<div style="text-align: left;"><span style="color: lime; font-family: Arial, Helvetica, sans-serif; font-size: medium;"><br />
</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">A 9 patch image is an image that has stretchable areas defined.</span><br style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">These areas are defined in a special 1 pixel wide border around the area. Add black pixels to the top and left of this border to describe where the image can be stretched horizontally and vertically.</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="font-size: medium;"><span style="color: lime;">Why Use 9 Patch Images?</span></span></span><br />
<br />
<div style="text-align: left;"><span style="color: lime; font-family: Arial, Helvetica, sans-serif; font-size: medium;"><br />
</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">Nine patch images are especially useful when designing buttons. Custom drawn buttons can look distorted and pixelated when their borders are stretched in addition to the rest of the image.</span><br style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><br style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="font-size: medium;"><span style="color: lime;">Creating 9 Patch Images</span></span></span><br />
<br />
<div style="text-align: left;"><span style="color: lime; font-family: Arial, Helvetica, sans-serif; font-size: medium;"><br />
</span></div><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">Making a 9 Patch image is a fairly easy process. Included as part of the Android SDK is a Draw 9 Patch utility. Navigate to the folder where you installed the SDK. From there navigate to the tools folder. Inside this folder will be the draw 9 patch program. On Windows, double click on draw9patch.bat</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><br />
</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4ijfpc0n2i1plXk2MYqR2Tjbd_solQvBInXkGv9wAyTQRv3QpE172R5bQ3tQbFvh4dk2fbTdVa8UcsxGQmJia6kLoAlqf07uCIML0-VQ6fy7YBVMGqBX0A4fyOD2K9ItA12uiv7Ce6I/s1600/draw9patchbat.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="403" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_4ijfpc0n2i1plXk2MYqR2Tjbd_solQvBInXkGv9wAyTQRv3QpE172R5bQ3tQbFvh4dk2fbTdVa8UcsxGQmJia6kLoAlqf07uCIML0-VQ6fy7YBVMGqBX0A4fyOD2K9ItA12uiv7Ce6I/s640/draw9patchbat.png" width="640" /></a></div><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; color: #444444; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><br />
</span></span><br />
<span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;">Once the Draw 9 Patch program has started, simply drag an image that you would like to edit onto the program.</span></span> <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDaeIt9Lxcp4Kf68DR4sofIo04Uj4Rzy6IJHE8k62rhi9q_BUs6xs7BDyTdWG-Sv-D8qzR3ZpSQaKl97CMXpljamBJL16nwuNLw3aDa9n1_j1BxHakyLp2glIv8cOjZ8v6xb6zpRKHv3k/s1600/draw9patchstart.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="416" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDaeIt9Lxcp4Kf68DR4sofIo04Uj4Rzy6IJHE8k62rhi9q_BUs6xs7BDyTdWG-Sv-D8qzR3ZpSQaKl97CMXpljamBJL16nwuNLw3aDa9n1_j1BxHakyLp2glIv8cOjZ8v6xb6zpRKHv3k/s640/draw9patchstart.png" width="640" /></a></div><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></span><br />
<span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;">After an image has been loaded into the Draw 9-Patch program two panes of information will appear. The left pane is used to edit the patches. The right pane shows what the image will look like when it is stretched in a couple of different ways.</span></span> <br />
<span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjseljvwfL3CT6zkRRaAz-zfY-WsSsHdTGen6E7b4nU8qEv8R1nxU8JfPkH-YFGmqfholfhKZ5c10Ejd4Skt1ewOCUsUNnon6jlAjsNY5P4atRkwah0_JI4Zbrs9UGDFZE5byY8GCbBGAs/s1600/android-9patch-before-edit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="524" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjseljvwfL3CT6zkRRaAz-zfY-WsSsHdTGen6E7b4nU8qEv8R1nxU8JfPkH-YFGmqfholfhKZ5c10Ejd4Skt1ewOCUsUNnon6jlAjsNY5P4atRkwah0_JI4Zbrs9UGDFZE5byY8GCbBGAs/s640/android-9patch-before-edit.png" width="640" /></a></div><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span></span><br />
<br />
<div style="background-color: white; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-size: medium;"><span style="color: lime;">Drawing the Patches</span></span></div><br style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">You can think of the Draw 9 Patch program as a simple image editor, but you can only change the 1 pixel border and you can only use the color black.</span><br style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><br style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">Draw along the top of the image to define the area that can be stretched horizontally. Draw along the left side of the image to define the area that can be stretched vertically. Draw along the bottom and the right of the image to define the padding. Holding down shift and clicking will erase pixels.</span></span> <br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><br />
</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijYHek9SVD63rfzgMIfZV5cQyFgOTr2GrVypWwxXf4On-w4eDUN6pgU00UyLDcUMgHw4-x7cX9VGqMuKD-ubOq4xB0QomvyboZ83S1i0nbzuA48w5Hix55OtXl25d7lT4O0_n-q3lrvoU/s1600/android-9patch-after-edit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="524" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijYHek9SVD63rfzgMIfZV5cQyFgOTr2GrVypWwxXf4On-w4eDUN6pgU00UyLDcUMgHw4-x7cX9VGqMuKD-ubOq4xB0QomvyboZ83S1i0nbzuA48w5Hix55OtXl25d7lT4O0_n-q3lrvoU/s640/android-9patch-after-edit.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">If you have the "Show Patches" option selected, then the stretchable area will be highlighted in pink.</span></span><br />
<div style="background-color: white; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 22px; text-align: -webkit-auto;"><span style="font-size: medium;"><span style="color: lime;">.9.png File Extension</span></span></div><br style="background-color: white; color: #444444; font-family: Verdana, Geneva, sans-serif; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="font-family: Arial, Helvetica, sans-serif;"><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">Your nine patch images must be saved with the .9.png file extension in order for Android to recognize and handle them properly. Failure to do so may result in unpredictable results.</span><br style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><br style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;" /><span style="background-color: white; font-size: 13px; line-height: 22px; text-align: -webkit-auto;">When you save from the Draw 9-Patch program it will have the proper extension.</span></span> <br />
<br />
<br />
<br />
<br />
<br />
<span style="color: lime; font-family: Arial, Helvetica, sans-serif; font-size: large;">Optional controls include:</span><br />
<br />
<span style="color: lime;">Zoom:</span> Adjust the zoom level of the graphic in the drawing area.<br />
<span style="color: lime;">Patch scale:</span> Adjust the scale of the images in the preview area.<br />
<span style="color: lime;">Show lock:</span> Visualize the non-drawable area of the graphic on mouse-over.<br />
<span style="color: lime;">Show patches:</span> Preview the stretchable patches in the drawing area (pink is a stretchable patch).<br />
Show content: Highlight the content area in the preview images (purple is the area in which content is allowed).<br />
<span style="color: lime;">Show bad patches:</span> Adds a red border around patch areas that may produce artifacts in the graphic when stretched. Visual coherence of your stretched image will be maintained if you eliminate all bad patches.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2A0jZBh30csop0nvZOhFYzC_bz4HkceO4mh8Anzjn9Jp9S5HA3BR_OG_gPnF03c-eqW_2TQoj_ChFGFDlXNuNuDv3yzftPevsf__669Wg9ElleKYfla5TgyklLygTHe2WW33GwhCIYrY/s1600/9patch1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="562" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2A0jZBh30csop0nvZOhFYzC_bz4HkceO4mh8Anzjn9Jp9S5HA3BR_OG_gPnF03c-eqW_2TQoj_ChFGFDlXNuNuDv3yzftPevsf__669Wg9ElleKYfla5TgyklLygTHe2WW33GwhCIYrY/s640/9patch1.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><span style="color: lime; font-family: Arial, Helvetica, sans-serif; font-size: large;">Here are some examples</span><div><br />
</div><div><span style="color: lime;"> Simple button</span><div><br />
</div><div>This is a just simple button, with a glowing effect. The 9patching wich I use here, keeps the button’s edges, so it keeps the rounded rectangle’s radius too. With 9patch, the content area of the button can be set easily.</div></div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlaYOsLd1MLWLTpbKzpIIL1zCDjxv-xcAASanAPf5uYBldLCq709cC1SG_2I9hKJs_xO4HmiuABtb6z1G1SNZhP8zTrODEMNq7WsP3xrxjb1UAMR39GXiyim43TQMhf_BEXcPm7OsAdsc/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlaYOsLd1MLWLTpbKzpIIL1zCDjxv-xcAASanAPf5uYBldLCq709cC1SG_2I9hKJs_xO4HmiuABtb6z1G1SNZhP8zTrODEMNq7WsP3xrxjb1UAMR39GXiyim43TQMhf_BEXcPm7OsAdsc/s640/9patch.jpg" width="538" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<span style="color: lime;">Spinner button</span><div><br />
</div><div>This is a chooser button, with the same glowing effect. With this 9patching, the dropdown arrow keeps it’s size at horizontal stretching. The glowing effect stays in the middle of the button.<div><br />
</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBbEZzot0f-Z826BPlP0mHMWavDGGVknp4CZ_tx-wm85-4vEh7fn5vbLJ_KOek2xFpqWYIFf8pLgTyqE8vvPYhBga1YF8wclv3VV7LVAoV8vvlgk_q58U9gVDWoI0pcQFRc3cXUM5KaQw/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBbEZzot0f-Z826BPlP0mHMWavDGGVknp4CZ_tx-wm85-4vEh7fn5vbLJ_KOek2xFpqWYIFf8pLgTyqE8vvPYhBga1YF8wclv3VV7LVAoV8vvlgk_q58U9gVDWoI0pcQFRc3cXUM5KaQw/s640/9patch.jpg" width="538" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<br />
<br />
<span style="color: lime;">Article header image</span><div><br />
</div><div>In this case, I use an extra transparent line before and below the image. The 9patch stretches this lines out. The picture always align to the right top corner of the layout. This can be a spectacular articleheader background. </div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGE-4HnxEfhmsBlboxwmqquAg94RaXmwIjTA_QpqY0rKeGrLXHoi1NheCk2CpdVsAYtDjxPU-XzqtX7Omzd0XiGqekklnYwzVoPnqRVFCYp8DzEMTz9X6RN8s3fTmBLdUd1cJ_G8cG68/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFGE-4HnxEfhmsBlboxwmqquAg94RaXmwIjTA_QpqY0rKeGrLXHoi1NheCk2CpdVsAYtDjxPU-XzqtX7Omzd0XiGqekklnYwzVoPnqRVFCYp8DzEMTz9X6RN8s3fTmBLdUd1cJ_G8cG68/s640/9patch.jpg" width="538" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<span style="color: lime;">Header background</span><div><br />
</div><div>Like at web pages, larger background images can created easily from a tiny picture. This 9patch stretches the middle of the image, so it’s look like continuous. The lenght of the layout doesn’t matter. For example, this is useful when creating menu bars.<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOI9xi8ec52topwK2D9Uif_Rq1ojBW8ubUzrFt-kevxTASuDdqyAKe_g_oBbQycRxFrWK0PH35qSvQikT12q4aVOKEc7fVgcobig1e1RbdeHaO2dZWMJx-nDLhACEBwdZf9PfytWaAzMk/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOI9xi8ec52topwK2D9Uif_Rq1ojBW8ubUzrFt-kevxTASuDdqyAKe_g_oBbQycRxFrWK0PH35qSvQikT12q4aVOKEc7fVgcobig1e1RbdeHaO2dZWMJx-nDLhACEBwdZf9PfytWaAzMk/s640/9patch.jpg" width="538" /></a></div><br />
<span style="color: lime;"> Header background 2</span></div><div><br />
</div><div>In this example, I use the last column of the image, for horizontal stretch. This must be a single-color column. The image starts at the left side of the layout, in any cases, and fill the end with the single-color. </div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvpp5IEYAaybKswuYyKRr4nZSAxJTIlzjGNwgow0XFI6Qas8fYChc228soVJZKPDBK1m13O8ihKlUMQDWaziYJUrLFxL6yC_fJ4WgzmmR1R1c7jBlJz6aW_foJUhb4Ty4gCywmPP_q00/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvpp5IEYAaybKswuYyKRr4nZSAxJTIlzjGNwgow0XFI6Qas8fYChc228soVJZKPDBK1m13O8ihKlUMQDWaziYJUrLFxL6yC_fJ4WgzmmR1R1c7jBlJz6aW_foJUhb4Ty4gCywmPP_q00/s640/9patch.jpg" width="538" /></a></div><br />
<span style="color: lime;">Search EditText</span><div><br />
</div><div>You can create your own, horizontal stretch - independent EditText with 9patching. Take care of setting the content area of the image, see it below.<div><br />
</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEincpjwyBWSodBLyV-QceZ4bP_LqMU-vCFr-_d2aaAUOasMGgQ-wAI8BFZdsAt4xu6DCOYRe-gfxEwRpcpak1RfA7-31vAjEu6gum4fiHri1f3s51inT4pWAfmbjP9viUEVzJ-GaM65eQU/s1600/9patch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEincpjwyBWSodBLyV-QceZ4bP_LqMU-vCFr-_d2aaAUOasMGgQ-wAI8BFZdsAt4xu6DCOYRe-gfxEwRpcpak1RfA7-31vAjEu6gum4fiHri1f3s51inT4pWAfmbjP9viUEVzJ-GaM65eQU/s640/9patch.jpg" width="538" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div><br />
</div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-57044502773209444652012-03-30T08:21:00.000-07:002012-03-30T08:21:07.792-07:00Custom radio button and checkbox in android<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Anybody know that real cool Android application must have not only excelent business logic. The one of the most important things what application must have is a nice UI.<br />
If you want to create realy interesting application you need to create good UI. And …. hire a designer <br />
Below i want to tell you how to create your own CheckBoxes and RadioButtons for your Android Applications. Sorry for this sample UI design. I didn’t hire a designer :).<br />
First look at video of that:<br />
<div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/xh42vTcz5mI?feature=player_embedded' frameborder='0'></iframe></div><br />
<br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView1"
android:layout_height="wrap_content"
android:text="Custom Radio Button "/>
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:text="Cool"
android:button="@drawable/my_ratingbar"
android:layout_height="wrap_content"
android:id="@+id/radio0"
android:layout_width="134dp"/>
<RadioButton
android:text="Sexy"
android:button="@drawable/my_ratingbar"
android:layout_height="wrap_content"
android:id="@+id/radio1"
android:checked="true"
android:layout_width="wrap_content"/>
<RadioButton
android:text="Both"
android:button="@drawable/my_ratingbar"
android:layout_height="wrap_content"
android:id="@+id/radio2"
android:layout_width="wrap_content"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="20dp"
android:id="@+id/textView1"
android:layout_height="wrap_content"
android:text="Custom Check Box "/>
<CheckBox
android:text="CheckBox1"
android:id="@+id/checkBox1"
android:checked="true"
android:button="@drawable/my_ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox
android:text="CheckBox2"
android:id="@+id/checkBox2"
android:button="@drawable/my_ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginTop="20dp"
android:id="@+id/textView1"
android:layout_height="wrap_content"
android:text="http://developer-dot-android.blogspot.com"/>
</LinearLayout></pre><br />
<br />
</div><br />
<br />
my_ratingbar.xml<br />
<br />
<pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/red_holo" />
<item android:state_checked="false" android:drawable="@drawable/red_full" />
</selector>
</pre><br />
</div><div style="text-align: center;">red_holo</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW0vnwjKKCE4ysGjrrzyQA1em2eb36pe9v3Bc_3RF2emsRHIjLxq1OYyqr94q1A3lvUBGDziHUtU0cO_cdYocomPdr10PsvMx9e8xoeYcLCZXKMXmZZPZ8X3gMFt_6mIA8jwEBKKLH38Y/s1600/red_holo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW0vnwjKKCE4ysGjrrzyQA1em2eb36pe9v3Bc_3RF2emsRHIjLxq1OYyqr94q1A3lvUBGDziHUtU0cO_cdYocomPdr10PsvMx9e8xoeYcLCZXKMXmZZPZ8X3gMFt_6mIA8jwEBKKLH38Y/s1600/red_holo.png" /></a></div><div style="text-align: center;"><br />
</div><div style="text-align: center;"><br />
</div><div style="text-align: center;">red_full</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/AVvXsEhq_6kWz2HOZVMzrn6sG9kjhw_IjERm0M30Kw8O6B8hFe4zaIrskDLzq5yK_suUtbcWcOh0UCXEfBbKaXi8sx02rhEgmgzRQeLaO8fPc12RbJi7EN5iB9LUQJL_kxH51Ug7G8iiQdoLoGM/s1600/red_full.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq_6kWz2HOZVMzrn6sG9kjhw_IjERm0M30Kw8O6B8hFe4zaIrskDLzq5yK_suUtbcWcOh0UCXEfBbKaXi8sx02rhEgmgzRQeLaO8fPc12RbJi7EN5iB9LUQJL_kxH51Ug7G8iiQdoLoGM/s1600/red_full.png" /></a></div><br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com1tag:blogger.com,1999:blog-5740027206976638755.post-56275380850548782092012-03-26T05:32:00.000-07:002012-03-26T05:32:49.971-07:00Marquee effect in TextView tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Here is the code</div><br />
xml File<br />
<br />
<pre class="brush: csharp"><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="Simple application that shows how to use marquee, with a long text" />
</RelativeLayout>
</pre><br />
java file <br />
<br />
<pre class="brush: csharp">public class TextViewMarquee extends Activity {
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) this.findViewById(R.id.tv);
tv.setSelected(true); // Set focus to the textview
}
}
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-11137697614238271272012-03-22T22:49:00.000-07:002012-03-22T22:49:31.457-07:00Sending Emails without User Interaction in Android<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">In this article I'm going to show you how to send an email in the background without the user even knowing - the application will do everything behind the scenes.</span></div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Before we begin, you'll need to download a few files via the link below - this is a special version of the JavaMail API, which was written specifically for Android.</span></div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="border-bottom-color: rgb(163, 163, 163); border-bottom-style: dotted; border-bottom-width: 1px; color: red; font-family: Arial, Helvetica, sans-serif; text-decoration: none;"><a href="http://code.google.com/p/javamail-android/downloads/list" style="border-bottom-color: rgb(163, 163, 163); border-bottom-style: dotted; border-bottom-width: 1px; text-decoration: none;">http://code.google.com/p/javamail-android/downloads/list</a> <a href="http://developer-dot-android.blogspot.com/2012/03/how-to-add-jar-file-in-android-project.html" target="_blank">(how to add jar file in your project ?)</a></span></div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><br />
</div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">I'll be walking you through a Mail wrapper that I wrote, which makes it much easier to send emails and even add attachments if that's something you'd like to do.</span></div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Here is the full wrapper class below, which I'll go through step by step - keeping in mind that you'll have to add the fore-said files if you want this to work. Add them as external libraries - they need to be accessible by the Mail class.</span></div><div style="background-color: white; padding-bottom: 10px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="background-color: transparent;"><br />
</span><br />
<span style="background-color: transparent;"></span></div></div><pre class="brush: csharp">import java.util.Date;
import java.util.Properties;
import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.activation.MailcapCommandMap;
import javax.mail.BodyPart;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
public class Mail extends javax.mail.Authenticator {
private String _username;
private String _password;
private String[] _to;
private String _from;
private String _port;
private String _sport;
private String _host;
private String _subject;
private String _body;
private boolean _auth;
private boolean _debuggable;
private Multipart _multipart;
public Mail() {
_host = "smtp.gmail.com"; // default smtp server
_port = "465"; // default smtp port
_sport = "465"; // default socketfactory port
_username = ""; // username
_password = ""; // password
_from = ""; // email sent from
_subject = ""; // email subject
_body = ""; // email body
_debuggable = false; // debug mode on or off - default off
_auth = true; // smtp authentication - default on
_multipart = new MimeMultipart();
// There is something wrong with MailCap, javamail can not find a
// handler for the multipart/mixed part, so this bit needs to be added.
MailcapCommandMap mc = (MailcapCommandMap) CommandMap
.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);
}
public Mail(String user, String pass) {
this();
_username = user;
_password = pass;
}
public boolean send() throws Exception {
Properties props = _setProperties();
if (!_username.equals("") && !_password.equals("") && _to.length > 0
&& !_from.equals("") && !_subject.equals("")
&& !_body.equals("")) {
Session session = Session.getInstance(props, this);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(_from));
InternetAddress[] addressTo = new InternetAddress[_to.length];
for (int i = 0; i < _to.length; i++) {
addressTo[i] = new InternetAddress(_to[i]);
}
msg.setRecipients(MimeMessage.RecipientType.TO, addressTo);
msg.setSubject(_subject);
msg.setSentDate(new Date());
// setup message body
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(_body);
_multipart.addBodyPart(messageBodyPart);
// Put parts in message
msg.setContent(_multipart);
// send email
Transport.send(msg);
return true;
} else {
return false;
}
}
public void addAttachment(String filename) throws Exception {
BodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
_multipart.addBodyPart(messageBodyPart);
}
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(_username, _password);
}
private Properties _setProperties() {
Properties props = new Properties();
props.put("mail.smtp.host", _host);
if (_debuggable) {
props.put("mail.debug", "true");
}
if (_auth) {
props.put("mail.smtp.auth", "true");
}
props.put("mail.smtp.port", _port);
props.put("mail.smtp.socketFactory.port", _sport);
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
return props;
}
// the getters and setters
public String getBody() {
return _body;
}
public void setBody(String _body) {
this._body = _body;
}
public void sendTo(String[] _to) {
this._to = _to;
}
public void sendFrom(String _from) {
this._from = _from;
}
public void setSubject(String _subject) {
this._subject = _subject;
}
// more of the getters and setters …..
}
</pre>And now I'm going to go through each bit of code</div><br />
<pre class="brush: csharp">public Mail() {
_host = "smtp.gmail.com"; // default smtp server
_port = "465"; // default smtp port
_sport = "465"; // default socketfactory port
_username = ""; // username
_password = ""; // password
_from = ""; // email sent from
_subject = ""; // email subject
_body = ""; // email body
_debuggable = false; // debug mode on or off - default off
_auth = true; // smtp authentication - default on
_multipart = new MimeMultipart();
// There is something wrong with MailCap, javamail can not find a
// handler for the multipart/mixed part, so this bit needs to be added.
MailcapCommandMap mc = (MailcapCommandMap) CommandMap
.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);
}
public Mail(String user, String pass) {
this();
_username = user;
_password = pass;
}
</pre><br />
In this piece of code we initialise the properties, and setup the default values.<br />
Also, we're setting up the mime types for javamail. I've also added a comment which describes why we need this.<br />
And you've probably noticed that there are 2 constructors - one overrides the other, just incase the you want to pass the username and password when instantiating the class.<br />
<br />
<pre class="brush: csharp">public boolean send() throws Exception {
Properties props = _setProperties();
if (!_username.equals("") && !_password.equals("") && _to.length > 0
&& !_from.equals("") && !_subject.equals("")
&& !_body.equals("")) {
Session session = Session.getInstance(props, this);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(_from));
InternetAddress[] addressTo = new InternetAddress[_to.length];
for (int i = 0; i < _to.length; i++) {
addressTo[i] = new InternetAddress(_to[i]);
}
msg.setRecipients(MimeMessage.RecipientType.TO, addressTo);
msg.setSubject(_subject);
msg.setSentDate(new Date());
// setup message body
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(_body);
_multipart.addBodyPart(messageBodyPart);
// Put parts in message
msg.setContent(_multipart);
// send email
Transport.send(msg);
return true;
} else {
return false;
}
}
</pre>This is the most important method - here we're putting all the data from the properties and sending the mail. <br />
<pre class="brush: csharp">public void addAttachment(String filename) throws Exception {
BodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
_multipart.addBodyPart(messageBodyPart);
}
</pre>You can call this method at any time if you want to add an attachment, but make sure you call it before the send method. <br />
<pre class="brush: csharp">private Properties _setProperties() {
Properties props = new Properties();
props.put("mail.smtp.host", _host);
if (_debuggable) {
props.put("mail.debug", "true");
}
if (_auth) {
props.put("mail.smtp.auth", "true");
}
props.put("mail.smtp.port", _port);
props.put("mail.smtp.socketFactory.port", _sport);
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
return props;
}
</pre>Here we're setting up the properties for the mail retrieval - defaulting to SMTP authentication. Also keep in mind that this is all defaulted to connect to the Gmail (Google) SMTP server. Below is an example of how to use the Mail wrapper, in an Android activity. <br />
<pre class="brush: csharp">@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (mEmail.getText().toString().equals(
appPrefs.getEmail())) {
Mail m = new Mail("email@gmail.com", "password");
String[] toArr = {mEmail.getText().toString()};
m.sendTo(toArr);
m.sendFrom("email@gmail.com");
m.setSubject("Password");
m.setBody("This is your password : " + appPrefs.getPassword());
try {
m.addAttachment("/sdcard/filelocation");
if(m.send()) {
Toast.makeText(password.this, "Email was sent successfully.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(password.this, "Email was not sent.", Toast.LENGTH_LONG).show();
}
} catch(Exception e) {
//Toast.makeText(MailApp.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
Log.e("Password", "Could not send email", e);
}
} else {
Toast
.makeText(
getBaseContext(),
"This is not that email which you enter when create account",
Toast.LENGTH_LONG).show();
}
}
});
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com13tag:blogger.com,1999:blog-5740027206976638755.post-24136800991735399702012-03-22T22:36:00.000-07:002012-03-22T22:36:40.606-07:00how to add Jar file in android project ?<div dir="ltr" style="text-align: left;" trbidi="on">First of all download your jar file which you want to attach with your project<br />
<br />
then right click on your project and select properties<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF2q3-CQFfH54NWtBRR1GtOnFJwHcQT2LQ0HVG001tDk2xWXXs40_Hqwxha7AcvDw0wxCmVFUL7DdIOaBJIQlktUIjbS3FV3dqBZkO-fjfWuw3gB5BNLxvNsBNaiS-J3KI0dueR0cV9Fo/s1600/project+properties.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF2q3-CQFfH54NWtBRR1GtOnFJwHcQT2LQ0HVG001tDk2xWXXs40_Hqwxha7AcvDw0wxCmVFUL7DdIOaBJIQlktUIjbS3FV3dqBZkO-fjfWuw3gB5BNLxvNsBNaiS-J3KI0dueR0cV9Fo/s320/project+properties.png" width="161" /></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;">Then select Java Build Path from left panel </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmCaSXrMt7q2g3FHlmJVJNwL54IlSd7VnIKDjCMc6K8G86igrUvQDx7zlIDPcwO_A7MWXWu8Xl5d8PW-Mj_fsbONf9QNRScJ7v557fYVe8HPhpqc0oNFoYEOrSzQSKh038HyDfYwW0nck/s1600/java+build+path.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmCaSXrMt7q2g3FHlmJVJNwL54IlSd7VnIKDjCMc6K8G86igrUvQDx7zlIDPcwO_A7MWXWu8Xl5d8PW-Mj_fsbONf9QNRScJ7v557fYVe8HPhpqc0oNFoYEOrSzQSKh038HyDfYwW0nck/s320/java+build+path.png" width="231" /></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;">Then Select Libraries from up panel and click on Add External JARs...</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk6pEtOMrGJfv01lbknt4M_bZvgcbi1M2BSR6YKseo8vYbkt9E1kLfSeGIDFuNEbi7fuYyzDy0kIgXN6LmOSinfhwfDr-lkwjIEG36_MlsyCqhElTlN7_GMc2iO8sJSAwjSF0uROVKJ1U/s1600/java+build+path+libraries.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk6pEtOMrGJfv01lbknt4M_bZvgcbi1M2BSR6YKseo8vYbkt9E1kLfSeGIDFuNEbi7fuYyzDy0kIgXN6LmOSinfhwfDr-lkwjIEG36_MlsyCqhElTlN7_GMc2iO8sJSAwjSF0uROVKJ1U/s320/java+build+path+libraries.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Select your jar file and click Open</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: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha2U7EUAfEk_Kua5yFhQD8BpqRQZ7BoGMroP_f9Rs7gAKcP058lB8slgXEmmdc2MbNEYvJK9y5TsPRzqqJR4oiq-pfeNuYxxQv3xN5xnC7l2eAVqQEYUJirNB-ZcyUoOC8HLwE06y8I1A/s1600/select+your+jar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="110" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha2U7EUAfEk_Kua5yFhQD8BpqRQZ7BoGMroP_f9Rs7gAKcP058lB8slgXEmmdc2MbNEYvJK9y5TsPRzqqJR4oiq-pfeNuYxxQv3xN5xnC7l2eAVqQEYUJirNB-ZcyUoOC8HLwE06y8I1A/s320/select+your+jar.png" width="320" /></a></div><br />
Now you can see that jar file is added in your project now click Ok<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj30tO9J6QOTfJP7TqCKakcLMFMraHSM3PO1UXCt5YJ44J7dLZSUhs5fnG7mVqdT2ou_6wshmzgNxJAFDOFwlbG2WwEUTYqsOr8T8MVUaINtANhu6JPgeB0FAnktWKi5B3dbzQjanPzfRU/s1600/jar+added.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj30tO9J6QOTfJP7TqCKakcLMFMraHSM3PO1UXCt5YJ44J7dLZSUhs5fnG7mVqdT2ou_6wshmzgNxJAFDOFwlbG2WwEUTYqsOr8T8MVUaINtANhu6JPgeB0FAnktWKi5B3dbzQjanPzfRU/s320/jar+added.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Thats it...share if you like or this tutorial is help you..</div><br />
<br />
<br />
<br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-87602019774797035032012-03-22T09:01:00.000-07:002012-03-22T09:01:11.402-07:00SharedPreferences Between two Activity<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Create One class with name AppPreferences<br />
<br />
</div><pre class="brush: csharp">import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
public class AppPreferences {
private static final String APP_SHARED_PREFS = "com.chirag.saga.password";
private SharedPreferences appSharedPrefs;
private Editor prefsEditor;
public AppPreferences(Context context) {
this.appSharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS,
Activity.MODE_PRIVATE);
this.prefsEditor = appSharedPrefs.edit();
}
public String getPassword() {
return appSharedPrefs.getString("password", "0000");
}
public void savePassword(String text) {
prefsEditor.putString("password", text);
prefsEditor.commit();
}
}</pre><br />
Then in your Activity...<br />
<br />
<pre class="brush: csharp">protected AppPreferences appPrefs;
appPrefs = new AppPreferences(getApplicationContext());
</pre><br />
and <br />
<pre class="brush: csharp">String someString = appPrefs.getPassword();
or
appPrefs.savePassword(someString);
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-84299864048188171582012-03-20T09:28:00.000-07:002012-03-20T09:28:34.109-07:00How to show html page from asserts<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
</div><pre class="brush: csharp">mWebView.loadUrl("file:///android_asset/main.html");
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setScrollContainer(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSaveFormData(true);
mWebView.getSettings().setBuiltInZoomControls(false);
mWebView.addJavascriptInterface(new JavaScriptInterface(this),"Android");
mWebView.setWebChromeClient(new WebChromeClient()
{
// Show javascript logs in LogCat
public void onConsoleMessage(String message, int lineNumber,String sourceID)
{
Log.d("MyApplication", message + " -- From line " + lineNumber + " of " + sourceID);
}
});
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-17855288997536832482012-03-19T05:22:00.000-07:002012-03-19T05:22:25.247-07:00WHAT IS ANDROID ?<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.0001pt; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.<br />
<span class="Apple-style-span" style="color: lime; font-size: 23px; font-weight: bold; line-height: normal;"><br />
</span><br />
<span class="Apple-style-span" style="color: lime; font-size: 23px; font-weight: bold; line-height: normal;">Features</span></div><ul style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2em; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Application framework</strong> enabling reuse and replacement of components</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Dalvik virtual machine</strong> optimized for mobile devices</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Integrated browser</strong> based on the open source WebKit engine</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Optimized graphics</strong> powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>SQLite</strong> for structured data storage</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Media support</strong> for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>GSM Telephony</strong> (hardware dependent)</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Bluetooth, EDGE, 3G, and WiFi</strong> (hardware dependent)</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Camera, GPS, compass, and accelerometer</strong> (hardware dependent)</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Rich development environment</strong> including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE</li>
</ul><a href="http://www.blogger.com/post-edit.g?blogID=6027369586503817722&postID=1736267149561260034" id="os_architecture" name="os_architecture" style="color: #006699;"></a><br />
<span class="Apple-style-span" style="color: lime; font-size: large;"><b>Android Architecture</b></span><br />
<span class="Apple-style-span" style="color: lime;"><br />
</span><br />
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">The following diagram shows the major components of the Android operating system. Each section is described in more detail below.</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFG2M4c1FTVcAdLlB2PBOjeCld-ccPUx2rjKTJXczwpL8wYDI3cOBuEdXi0UpARBaBCFeOWkAYV_kCMPkriLQsfyhvM2HAX2OhSXxprc1WAGG0X0xTPfHZR-jNFUvWkXtS4D5e_toKxOA/s1600/Android+system+architecture.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="457" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFG2M4c1FTVcAdLlB2PBOjeCld-ccPUx2rjKTJXczwpL8wYDI3cOBuEdXi0UpARBaBCFeOWkAYV_kCMPkriLQsfyhvM2HAX2OhSXxprc1WAGG0X0xTPfHZR-jNFUvWkXtS4D5e_toKxOA/s640/Android+system+architecture.jpg" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><span class="Apple-style-span" style="background-color: white; color: lime; font-family: arial, sans-serif; font-size: large; font-weight: bold;">Applications</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"></span><br />
<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 20px;">Android will ship with a set of core applications including an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"><a href="http://www.blogger.com/post-edit.g?blogID=6027369586503817722&postID=1736267149561260034" id="application_framework" name="application_framework" style="color: #006699;"></a></span><br />
<br />
<span class="Apple-style-span" style="background-color: white; color: lime; font-family: arial, sans-serif; font-size: large;"><b>Application Framework</b></span><br />
<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 20px;">By providing an open development platform, Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more.</span><br />
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user.</span></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">Underlying all applications is a set of services and systems, including:</span></div><ul style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2em; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"><span class="Apple-style-span" style="color: #333333;">A rich and extensible set of </span><span class="Apple-style-span" style="color: blue;"><span class="Apple-style-span">Views</span> </span><span class="Apple-style-span" style="color: #333333;">that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser</span></span></li>
<span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="color: blue;">Content Providers</span><span class="Apple-style-span" style="color: #333333;"> that enable applications to access data from other applications (such as Contacts), or to share their own data</span></li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="color: #333333;">A </span><span class="Apple-style-span" style="color: blue;">Resource Manager</span><span class="Apple-style-span" style="color: #333333;">, providing access to non-code resources such as localized strings, graphics, and layout files</span></li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="color: #333333;">A </span><code style="line-height: 1em;"><span class="Apple-style-span" style="color: blue;">Notification Manager</span></code><span class="Apple-style-span" style="color: #333333;"> that enables all applications to display custom alerts in the status bar</span></li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="color: #333333;">An </span><code style="line-height: 1em;"><span class="Apple-style-span" style="color: blue;">Activity Manager</span></code><span class="Apple-style-span" style="color: #333333;"> that manages the lifecycle of applications and provides a common navigation backstack</span></li>
</span></ul><span class="Apple-style-span" style="background-color: white; color: lime; font-family: arial, sans-serif; font-size: large; font-weight: bold;">Libraries</span></div><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.0001pt; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 20px;">Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:</span></div><div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0.0001pt; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;"><ul style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 2em; padding-right: 0px; padding-top: 0px;"><li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"><strong>System C library</strong> - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices</span></li>
<span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Media Libraries</strong> - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>Surface Manager</strong> - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>LibWebCore</strong> - a modern web browser engine which powers both the Android browser and an embeddable web view</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>SGL</strong> - the underlying 2D graphics engine</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>3D libraries</strong> - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>FreeType</strong> - bitmap and vector font rendering</li>
<li style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.5em; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><strong>SQLite</strong> - a powerful and lightweight relational database engine available to all applications</li>
</span></ul><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"><a href="http://www.blogger.com/post-edit.g?blogID=6027369586503817722&postID=1736267149561260034" id="runtime" name="runtime" style="color: #006699;"></a></span><br />
<span class="Apple-style-span" style="background-color: white; color: lime; font-family: arial, sans-serif; font-size: large;">Android Runtime</span><br />
<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 20px;">Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language.</span><br />
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.</span></div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.</span></div><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"><span class="Apple-style-span" style="color: lime; font-size: large;"><b>Linux Kernel</b></span></span><br />
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #333333; line-height: 1.3em; margin-bottom: 1em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;">Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.</span></div></div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-4832484595743589752012-03-19T05:18:00.000-07:002012-03-19T05:18:36.102-07:00Load image from Link<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Load image from link to ImageView.</div><br />
<pre class="brush: csharp">Bitmap bitmap = BitmapFactory
.decodeStream((InputStream) new URL(
"http://www.diwaliwallpapers.com/images/wmwallpapers/Bhagwan-Swaminarayan-1.jpeg")
.getContent());
img.setImageBitmap(bitmap);
// where img is ImageView
</pre><br />
<br />
Don't Forgot to add permission in manifest file like this<br />
<br />
<pre class="brush: csharp"><uses-permission android:name="android.permission.INTERNET" />
</pre><br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-16322668187390747592012-03-19T05:10:00.000-07:002012-03-19T05:10:35.025-07:00Hide the notification bar<div dir="ltr" style="text-align: left;" trbidi="on">Write this on your OnCreate() methode<br />
<br />
<br />
<div class="p1"><br />
</div><pre class="brush: csharp">getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,</pre><pre class="brush: csharp">WindowManager.LayoutParams.FLAG_FULLSCREEN);
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-15244310640127348922012-03-17T05:44:00.000-07:002012-03-17T05:44:32.694-07:00Get Screen Size Of Device<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-size: large;"><b>get screen size of device</b></span></div><div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-size: large;"><b><br />
</b></span></div></div><pre class="brush: csharp">int windowHeight = getWindowManager().getDefaultDisplay().getHeight();
int windowWidth = getWindowManager().getDefaultDisplay().getWidth();
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-59645276609536177692012-03-17T05:40:00.002-07:002012-03-17T05:40:58.889-07:00Generate Random No<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;"><span class="Apple-style-span" style="font-size: large;"><b>generate Random no</b></span></div><div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;"><span class="Apple-style-span" style="font-size: large;"><b><br />
</b></span></div></div><pre class="brush: csharp">Random randfact = new Random();
Toast.makeText(getBaseContext(), "random no : "+ randfact.nextInt(10000), Toast.LENGTH_LONG).show();
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-12098642722280327652012-03-17T05:37:00.000-07:002012-03-17T05:37:27.468-07:00On Text Changed of EditText<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="font: normal normal normal 11px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-size: large;"><b>on Text changed of Edit text</b></span></div></div><br />
<pre class="brush: csharp">// on Text changed of Edit text
mEditText.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
Log.i("TextChanges","After textChanged");
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
Log.i("TextChanges", "before Text Changed");
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
Log.i("TextChanges", "On Text changed");
}
});</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-51600334852129012762012-03-17T05:33:00.000-07:002012-03-17T05:33:42.586-07:00Date into Day tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="font: 11.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;"><span class="Apple-style-span" style="font-size: large;">convert date into day</span></div></div><br />
<pre class="brush: csharp">SimpleDateFormat inFormat = new SimpleDateFormat("dd-MM-yyyy");
Date date = inFormat.parse(Yourdate);
SimpleDateFormat outFormat = new SimpleDateFormat("EEEE");
String goal = outFormat.format(date);
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-87351269125719160322012-03-17T05:28:00.000-07:002012-03-17T05:28:10.383-07:00Internet Connection check tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">How to check Internet Connection in android phone</div><br />
<pre class="brush: csharp">boolean connected = false;
ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
//we are connected to a network
connected = true;
}
else
connected = false;
</pre></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-87456804473390732902012-03-16T10:19:00.001-07:002012-03-16T10:20:19.629-07:00lifecycle events of Android Activity tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitVf3QfT0N2L2XZFRyebHydkZzOfBM9mPuukjAxVNqk0GWq73q1AysWDbdIX4zRAATkaXM0k-HypSKm9uTB_WyOiyIV8hITmYAJfXT06Y-hDmZuHvPBypcG-WSWhYheb7IZkY-C34dymg/s1600/logcat_example1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitVf3QfT0N2L2XZFRyebHydkZzOfBM9mPuukjAxVNqk0GWq73q1AysWDbdIX4zRAATkaXM0k-HypSKm9uTB_WyOiyIV8hITmYAJfXT06Y-hDmZuHvPBypcG-WSWhYheb7IZkY-C34dymg/s1600/logcat_example1.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/uname"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/Uname">
</TextView>
<EditText
android:id="@+id/utextbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/pass"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/Pass">
</TextView>
<EditText
android:id="@+id/ptextbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true">
</EditText>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="@+id/login"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="@string/Login">
</Button>
<Button
android:id="@+id/clear"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="@string/Clear">
</Button>
</LinearLayout>
</LinearLayout>
</pre><pre class="brush: csharp"></pre><pre class="brush: csharp"></pre><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIT-pv2fZaDmRwPcDayytSY71PviY8BjiaQE0NwNW8VR3QTFQiFtECC-zVisUZCZqCX-qjJDPTEA9CMTU4KyCgG5v_ndGjNzouwn3RNYhPIn4zoWma4D049sKeudY-jg5P2PgeH03Z2C4/s1600/logcat_example2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIT-pv2fZaDmRwPcDayytSY71PviY8BjiaQE0NwNW8VR3QTFQiFtECC-zVisUZCZqCX-qjJDPTEA9CMTU4KyCgG5v_ndGjNzouwn3RNYhPIn4zoWma4D049sKeudY-jg5P2PgeH03Z2C4/s1600/logcat_example2.png" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainLayout"
android:gravity="center">
<TextView
android:id="@+id/welcomeNote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Welcome !!"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center">
</TextView>
<Button
android:id="@+id/setting"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:text="@string/setting"
android:textSize="20dp"
android:gravity="center">
</Button>
</LinearLayout>
</pre><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCp-D-i7OmCIXjkML_adSa_LyeP1Asx2GIkBQxLJugdb-n91ooNWMjk6s2G0n3y6y5RtjN_UB_3HEvm6q9ZruIJKbK0ek7My24KJmIPKo6AQlm1fPCPaCQwG0bd28bu1bSmms4zElQJG0/s1600/logcat_example3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCp-D-i7OmCIXjkML_adSa_LyeP1Asx2GIkBQxLJugdb-n91ooNWMjk6s2G0n3y6y5RtjN_UB_3HEvm6q9ZruIJKbK0ek7My24KJmIPKo6AQlm1fPCPaCQwG0bd28bu1bSmms4zElQJG0/s1600/logcat_example3.png" /></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: center;"><br />
</div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:text="@string/msg"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/cs"
android:textSize="30dp"
android:gravity="center"
android:textColor="@color/yellow">
</TextView>
</LinearLayout>
</pre><b><span style="font-size: large;"><br />
</span></b><br />
<b><span style="color: blue; font-size: large;">Extra Files :</span></b><br />
<br />
<br />
<pre class="brush: csharp">strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Ex1Activity!</string>
<string name="app_name">Ex1</string>
<string name="Uname">User Name : </string>
<string name="Pass">Password : </string>
<string name="Login">Login</string>
<string name="Clear">Clear</string>
<string name="WelcomeNote">Welcome </string>
<string name="setting">Setting</string>
<string name="msg">Coming Soon...</string>
</resources>
color.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<color name="yellow">#FFFF00</color>
</resources>
</pre><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt;">Ex1Activity.java</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div><br />
<pre class="brush: csharp">package com.exc.first;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Ex1Activity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//read component from xml file
Button login = (Button)findViewById(R.id.login);
/**
* set OnClickListener on button
* so that code which is in between { } is run on click on login button
*/
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
/**
* make Intent to call other activity
* here Ex1Activity.this to go second.class
* on click login button
*/
Intent SecAct = new Intent(Ex1Activity.this,second.class);
//start second activity
startActivity(SecAct);
}
});
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
/**
* it show massage on LogCat when Activity starts
*/
Log.i("Login Activity", "Start");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
/**
* It show massage on LogCat when Activity OnPause
*/
Log.i("Login Activity", "Pause");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
/**
* it show massage on LogCat when Activity onRestart
*/
Log.i("Login Activity", "Restart");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
/**
* it show massage on LogCat when Activity OnResume
*/
Log.i("Login Activity", "Resume");
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
/**
* it show massage on LogCat when Activity Stop
*/
Log.i("Login Activity", "Stop");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
/**
* it show massage on LogCat when Activity Destroys
*/
Log.i("Login Activity", "Destroy");
}
}
</pre><br />
<span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt; line-height: 115%;">second.java </span><br />
<span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt; line-height: 115%;"><br />
</span><br />
<span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt; line-height: 115%;"><br />
</span><br />
<pre class="brush: csharp">package com.exc.first;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class second extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
//read button from xml file
Button setting =(Button)findViewById(R.id.setting);
setting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent goToSetting = new Intent(second.this,setting.class); //go to third Activity
startActivity(goToSetting);
}
});
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
/**
* it show massage on LogCat when Activity starts
*/
Log.i("Second Activity", "Start");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
/**
* it show massage on LogCat when Activity on pause
*/
Log.i("Second Activity", "Pause");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
/**
* it show massage on LogCat when Activity Restart
*/
Log.i("Second Activity", "Restart");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
/**
* it show massage on LogCat when Activity Resume
*/
Log.i("Second Activity", "Resume");
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
/**
* it show massage on LogCat when Activity stop
*/
Log.i("Second Activity", "Stop");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
/**
* it show massage on LogCat when Activity Destroy
*/
Log.i("Second Activity", "Destroy");
}
}
</pre></div><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt;">setting.java</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: 'Times New Roman', serif; font-size: 18pt;"><br />
</span></div><pre class="brush: csharp">package com.exc.first;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class setting extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.setting);
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
/**
* it show massage on LogCat when Activity starts
*/
Log.i("Third Activity", "Start");
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
/**
* it show massage on LogCat when Activity Pause
*/
Log.i("Third Activity", "Pause");
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
/**
* it show massage on LogCat when Activity Restarts
*/
Log.i("Third Activity", "Restart");
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
/**
* it show massage on LogCat when Activity Resume
*/
Log.i("Third Activity", "Resume");
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
/**
* it show massage on LogCat when Activity stop
*/
Log.i("Third Activity", "Stop");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
/**
* it show massage on LogCat when Activity Destroy
*/
Log.i("Third Activity", "Destroy");
}
}
</pre><br />
<br />
<div class="MsoNormal" style="margin-bottom: 5pt;"><span "times="" courier="" new'","serif";mso-fareast-font-family:="" new="" roman";color:red'="" roman";mso-bidi-font-family:"times="" style="font-family: "; font-size: 13.5pt;"><span style="color: red;">and don't forget to enter entry of your new java file into manifest file</span></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 5pt;"><span "times="" courier="" new'","serif";mso-fareast-font-family:="" new="" roman";color:red'="" roman";mso-bidi-font-family:"times="" style="font-family: "; font-size: 13.5pt;"><span style="color: red;"><br />
</span></span></div><div class="MsoNormal" style="margin-bottom: 5pt;"><span "times="" courier="" new'","serif";mso-fareast-font-family:="" new="" roman";color:red'="" roman";mso-bidi-font-family:"times="" style="font-family: "; font-size: 13.5pt;"><span style="color: red;"><br />
</span></span></div><br />
<pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exc.first"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Ex1Activity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".second"
android:label="@string/app_name">
</activity>
<activity android:name=".setting"
android:label="@string/app_name">
</activity>
</application>
</manifest>
</pre><br />
<div class="MsoNormal" style="margin-bottom: 5pt;"><span "times="" courier="" new'","serif";mso-fareast-font-family:="" new="" roman";color:red'="" roman";mso-bidi-font-family:"times="" style="font-family: "; font-size: 13.5pt;">Output<span style="color: red;"><br />
</span></span></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUWZLQTcq5NeBU79poOgBO2oEkd89pcSkAV9wiTalC1gm0SxyVN7DvJ12XUduZUcW4iSEJjl3HXssXm4WhYhIJIpA39soPXCohPJkD3nreu6az6I2dGquNj61mahH4WeOx1XaMzqh4vDI/s1600/output.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="175" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUWZLQTcq5NeBU79poOgBO2oEkd89pcSkAV9wiTalC1gm0SxyVN7DvJ12XUduZUcW4iSEJjl3HXssXm4WhYhIJIpA39soPXCohPJkD3nreu6az6I2dGquNj61mahH4WeOx1XaMzqh4vDI/s400/output.png" /></a></div><br />
<br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-68371007799652290382012-03-16T08:33:00.001-07:002012-03-25T18:18:14.125-07:00Custom Seekbar Tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: red; font-family: Monaco; font-size: large;"><b>seekbar_progress_bg.xml</b></span><span style="color: teal; font-family: Monaco;"><o:p></o:p></span></div><br />
<pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip >
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/green">
</bitmap>
</clip>
</item>
</layer-list>
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br />
<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><b><span style="color: red; font-size: large;">seekbar_progress.xml</span></b></span><span style="color: teal; font-family: Monaco;"><o:p></o:p></span></div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/whitepatch">
</nine-patch>
</item>
<item android:id="@android:id/secondaryProgress">
<clip >
<shape >
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8">
</gradient>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg">
</item>
</layer-list>
</pre></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: teal; font-family: Monaco;"><br />
</span><br />
<span style="color: teal; font-family: Monaco;"><br />
</span><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><span style="color: red; font-size: large;"><b>XML</b></span></span><span style="color: teal; font-family: Monaco;"><o:p></o:p></span></div><br />
<pre class="brush: csharp"><SeekBar
android:id="@+id/seekbar_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="420dip"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginTop="12dip"
android:maxHeight="9dp"
android:minHeight="9dp"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/shine_btn" />
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><span style="color: red; font-size: large;"><b><br />
</b></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><div class="separator" style="clear: both; text-align: center;">green.png</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZVOY4B0kIydsATv8zaMsSsM39mL3gcM-oCIUBRrHjqDuQqaOss1Kdzn5Q6aicBxLQmzvFLiyIyDfugF1zc2EA0ulgeFk1qlWUnL3prHcIrtHQ1NH-o9fZCEepNoDGSasKX9-B_PtIlN8/s1600/green.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="5" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZVOY4B0kIydsATv8zaMsSsM39mL3gcM-oCIUBRrHjqDuQqaOss1Kdzn5Q6aicBxLQmzvFLiyIyDfugF1zc2EA0ulgeFk1qlWUnL3prHcIrtHQ1NH-o9fZCEepNoDGSasKX9-B_PtIlN8/s320/green.png" width="320" /></a></div><div style="text-align: center;"><br />
</div><div style="text-align: center;">shine_btn.png</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1TdtEd-t2Xk44N6_-et4ZoqdkNfsYWVLP8EiGYo1eYID86b0nvJeW5jxj52eo7qHHaCmHuwyGawA0Aexzrs7Kjdt8f1s4R3DI5cVdvzcoFPE3kCiSdvzJVrQQk728SBtJpzqGpi8iu9Y/s1600/shine_btn.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1TdtEd-t2Xk44N6_-et4ZoqdkNfsYWVLP8EiGYo1eYID86b0nvJeW5jxj52eo7qHHaCmHuwyGawA0Aexzrs7Kjdt8f1s4R3DI5cVdvzcoFPE3kCiSdvzJVrQQk728SBtJpzqGpi8iu9Y/s1600/shine_btn.png" /></a></div><div style="text-align: center;">whitepatch.9.png</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8ef62ZJjOtUZ7OYcZlRKakJbN1AXPIjFE2Q3084NmG7c8BG3ZUFR-98C02_seebt_I3V_lNDivFBb1uE0K55AQ2rEb8UG1HTUPZOYI9uSEfeHXgEjIiX4bxepgtZ3CCHgrQrtN7fZ6P4/s1600/whitepatch.9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="8" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8ef62ZJjOtUZ7OYcZlRKakJbN1AXPIjFE2Q3084NmG7c8BG3ZUFR-98C02_seebt_I3V_lNDivFBb1uE0K55AQ2rEb8UG1HTUPZOYI9uSEfeHXgEjIiX4bxepgtZ3CCHgrQrtN7fZ6P4/s320/whitepatch.9.png" width="320" /></a></div><span style="font-family: Monaco;"><span style="color: red; font-size: large;"><b><br />
</b></span></span></div></div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-31787555522354605462012-03-16T05:28:00.002-07:002012-03-16T05:38:35.067-07:00Where did Sachin Tendulkar score his 100 centuries?<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-m9tUT9MXKVo/T2MyZK_vW2I/AAAAAAAABIE/-iIB7H563l4/s1600/Sachin-Tendulkar.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-m9tUT9MXKVo/T2MyZK_vW2I/AAAAAAAABIE/-iIB7H563l4/s320/Sachin-Tendulkar.jpg" width="275" /></a></div><br />
<br />
<a href="http://www.abc.net.au/news/2012-03-16/tendulkar-sachin-100th-century-map/3821040?section=sport">http://www.abc.net.au/news/2012-03-16/tendulkar-sachin-100th-century-map/3821040?section=sport</a></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0tag:blogger.com,1999:blog-5740027206976638755.post-17340187769032437022012-03-15T07:00:00.001-07:002012-03-16T05:01:32.805-07:00AutoCompleteTextView Tutorial<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">here is the layout xml file:<o:p></o:p></span></div><pre class="brush: csharp"><AutoCompleteTextView
android:id="@+id/AndroidBooks"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</AutoCompleteTextView></pre><div class="MsoNormal" style="margin-bottom: 0in;"><span style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;"> </span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">Nothing special. It just consists of one element.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">Now in the main activity, I create an array of android books:<o:p></o:p></span></div><pre class="brush: csharp">String[] androidBooks =
{
"Hello, Android - Ed Burnette",
"Professional Android 2 App Dev - Reto Meier",
"Unlocking Android - Frank Ableson",
"Android App Development - Blake Meike",
"Pro Android 2 - Dave MacLean",
"Beginning Android 2 - Mark Murphy",
"Android Programming Tutorials - Mark Murphy",
"Android Wireless App Development - Lauren Darcey",
"Pro Android Games - Vladimir Silva",
};
</pre><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">Then in the </span><span style="color: #262626; font-family: CourierNewPSMT; font-size: 15pt;">onCreate(..)</span><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"> method, I create an A</span><span style="color: #262626; font-family: CourierNewPSMT; font-size: 15pt;">rrayAdapter</span><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"> that I can pass to this</span><span style="color: #262626; font-family: CourierNewPSMT; font-size: 15pt;">AutoCompleteTextView</span><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"> as the data Source. <o:p></o:p></span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><br />
</div><pre class="brush: csharp">ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,androidBooks);
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br />
</div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">Then, I get a handle to the <a href="http://developer.android.com/reference/android/widget/AutoCompleteTextView.html"><span style="color: #498ac1; font-family: CourierNewPSMT; text-decoration: none;">AutocompleteTextView</span></a>, and set the </span><span style="color: #262626; font-family: CourierNewPSMT; font-size: 15pt;">arrayAdapter</span><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"> to it along with the Threshold. The Threshold defines the number of charaters a user should type before the suggestions start showing up.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><br />
</div><pre class="brush: csharp">AutoCompleteTextView acTextView = (AutoCompleteTextView)findViewById(R.id.acTVCountry);
acTextView.setThreshold(3);
acTextView.setAdapter(adapter);
</pre><pre class="brush: csharp"></pre><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">That is it. Now execute and see it work. <o:p></o:p></span></div><div align="center" class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-align: center; text-autospace: none;"><span style="font-family: Helvetica, sans-serif;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQkVDELh3Xhop6uim1A6hs-pnYbksUpYUvKuO6iKw186Ev-kzEYdgI1xAUg-3RZ96KAenPyPR8kkf7PeeZSJ62sSJiP01-X2GcJEOEoaqJOlPnxy0Eq9x7FnBKbHYem5CEGW5R4yA6AjU/s1600/AutoCompleteTextView.PNG.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQkVDELh3Xhop6uim1A6hs-pnYbksUpYUvKuO6iKw186Ev-kzEYdgI1xAUg-3RZ96KAenPyPR8kkf7PeeZSJ62sSJiP01-X2GcJEOEoaqJOlPnxy0Eq9x7FnBKbHYem5CEGW5R4yA6AjU/s400/AutoCompleteTextView.PNG.png" width="353" /></a></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;">This is the way it would look:</span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"><br />
</span></div><div class="MsoNormal" style="line-height: 20.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"><span style="color: #262626; font-family: ArialMT, sans-serif; font-size: 15pt;"><br />
</span></div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com1tag:blogger.com,1999:blog-5740027206976638755.post-52311844187932927892012-03-13T07:10:00.001-07:002012-03-16T06:41:10.530-07:00How to set gallery starts from left corner?<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<pre class="brush: csharp">/*
* A structure describing general information about a display, such as
* its size, density, and font scaling.To access the DisplayMetrics
* members, initialize an object like this:
*/
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Gallery g = (Gallery) findViewById(R.id.gallery);
// set gallery to left side
MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
mlp.setMargins(-(metrics.widthPixels / 2 + (imageWidth/2)), mlp.topMargin,
mlp.rightMargin, mlp.bottomMargin);
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: #3f7f5f; font-family: 'Courier New'; font-size: 10pt;"> </span></div><div class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzPRu2JwCWpWt7E9BeGKsyJb98mCEWT2_EfARw1VH1732pwMxeKlpIEVyDZBmEfWT0ZvQcsOt7B89hnVnfJZxSx_ZaIHSM_YjhPyt5J3vzrXTOTYEE0D5iUCl80KlsQSEu7zyDTmNwvvw/s1600/Gallery+left+side.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzPRu2JwCWpWt7E9BeGKsyJb98mCEWT2_EfARw1VH1732pwMxeKlpIEVyDZBmEfWT0ZvQcsOt7B89hnVnfJZxSx_ZaIHSM_YjhPyt5J3vzrXTOTYEE0D5iUCl80KlsQSEu7zyDTmNwvvw/s320/Gallery+left+side.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;"><a href="https://docs.google.com/open?id=0B2Ya1LFzrGR9MHRmaWpMX0dTOVNEMFlSQUJUX3NVZw" target="_blank"><span style="color: lime; font-size: large;">Download Source Code</span></a></div><div class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><br />
</div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com1tag:blogger.com,1999:blog-5740027206976638755.post-40060948131240506142012-03-12T12:46:00.003-07:002012-03-16T06:49:05.658-07:00Custom Dialog In Activity<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: 'Courier New';"><span style="font-size: large;"><b>TestActivity.java</b></span></span></div><pre class="brush: csharp">package com.chirag;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnShowDialog = (Button) findViewById(R.id.button1);
btnShowDialog.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog dialog = new Dialog(TestActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_layout);
dialog.setCancelable(true);
//there are a lot of settings, for dialog, check them all out!
//now that the dialog is set up, it's time to show it
dialog.show();
}
});
}
}
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;"><br />
</span></b></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 10pt;"><br />
</span></b></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: #7f0055; font-family: 'Courier New'; font-size: x-small;"><b><br />
</b></span></div><div class="MsoNormal"><span style="font-family: 'Courier New'; font-size: large;"><span style="line-height: 14px;"><b>main.xml</b></span></span></div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<TextView android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView1" android:layout_width="wrap_content"
android:text="Custom Dialog Example" android:layout_height="wrap_content"></TextView>
<Button android:text="Click Me to see Dialog" android:id="@+id/button1"
android:layout_marginTop="20dp" android:layout_gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</pre><div class="MsoNormal"><span style="font-family: 'Courier New'; font-size: large;"><span style="line-height: 14px;"><b><br />
</b></span></span></div><div class="MsoNormal"><span style="font-family: 'Courier New'; font-size: large;"><span style="line-height: 14px;"><b><br />
</b></span></span></div><div class="MsoNormal"></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: teal; font-family: 'Courier New'; font-size: x-small;"><br />
</span></div><div class="MsoNormal"><span style="color: teal; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="font-family: 'Courier New';"><span style="font-size: large;"><b>dialog_layout.xml</b></span></span></div><pre class="brush: csharp"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="100dp" android:id="@+id/imageView1"
android:src="@drawable/man" android:scaleType="fitXY"
android:layout_width="100dp"></ImageView>
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView1" android:layout_width="wrap_content"
android:text="Brandon" android:layout_height="wrap_content"></TextView>
<ImageView android:layout_height="wrap_content" android:id="@+id/imageView2"
android:layout_marginLeft="70dp" android:src="@android:drawable/btn_dialog"
android:layout_width="wrap_content"></ImageView>
</LinearLayout>
<View android:id="@+id/view1" android:layout_width="fill_parent"
android:background="@android:color/white" android:layout_height="2dp"></View>
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="10dp" android:id="@+id/textView2"
android:layout_width="wrap_content" android:layout_gravity="center_horizontal"
android:text=" How About dinner tonoght ? "
android:layout_height="wrap_content"></TextView>
<View android:id="@+id/view1" android:layout_width="fill_parent"
android:layout_marginTop="40dp" android:background="@android:color/white"
android:layout_height="2dp"></View>
<LinearLayout android:orientation="horizontal"
android:gravity="center_horizontal" android:layout_marginTop="5dp"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:id="@+id/imageButton1"
android:src="@android:drawable/ic_btn_speak_now"
android:layout_height="wrap_content" android:layout_width="wrap_content"></ImageButton>
<ImageButton android:id="@+id/imageButton2"
android:layout_marginLeft="10dp" android:src="@android:drawable/ic_lock_silent_mode_off"
android:layout_height="wrap_content" android:layout_width="wrap_content"></ImageButton>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_marginTop="5dp" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/editText1" android:hint="Type to Reply"
android:layout_width="220dp" android:layout_height="wrap_content">
</EditText>
<Button android:text="Reply" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
</pre><div class="MsoNormal"><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;"><br />
</span></i></div><div class="MsoNormal"><i><span style="color: #0000c0; font-family: 'Courier New'; font-size: 10pt;"><br />
</span></i></div><div class="MsoNormal"></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: teal; font-family: 'Courier New'; font-size: x-small;"><br />
</span></div><div class="MsoNormal"><o:p><b><span style="color: red; font-size: large;">Screen Shots</span></b></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red; font-size: large;"><br />
</span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuVWF3NUQNSyICkmKjgT1mlwgQ8GjGzZ9NYqseBx970hrarX2YlDb04_z1-XBz-jat1TNJd8WB8yqn6yttmaBkpKfflpHpLxgpoTzIhN2AmWG5FpNtgHkWLy92UMc_CDLR6I3eMmqH4nE/s1600/Custom_dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuVWF3NUQNSyICkmKjgT1mlwgQ8GjGzZ9NYqseBx970hrarX2YlDb04_z1-XBz-jat1TNJd8WB8yqn6yttmaBkpKfflpHpLxgpoTzIhN2AmWG5FpNtgHkWLy92UMc_CDLR6I3eMmqH4nE/s320/Custom_dialog.png" width="213" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy8ZABdhD_oSHNeCcw7gVD8u-RshyphenhyphenhbNY1YPAYlOsRYEfLz-V2VbBabFjC71c2DAFp2-3ic48GyKsn46FA8A36dWIzjjUE_umXn2bUm6i03bZS8Mz00t6yFMf-mqEmsPkNtxPqQy1MnEQ/s1600/Custom_dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy8ZABdhD_oSHNeCcw7gVD8u-RshyphenhyphenhbNY1YPAYlOsRYEfLz-V2VbBabFjC71c2DAFp2-3ic48GyKsn46FA8A36dWIzjjUE_umXn2bUm6i03bZS8Mz00t6yFMf-mqEmsPkNtxPqQy1MnEQ/s320/Custom_dialog.png" width="213" /></a></div><div class="MsoNormal"><o:p><b><span style="color: red; font-size: large;"><br />
</span></b></o:p></div><a href="https://docs.google.com/open?id=0B2Ya1LFzrGR9dVg5X0NUNndUa0c1SXVTUmk0MXFmQQ" target="_blank"><span style="color: lime; font-size: large;">Download Source Code</span></a></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com1tag:blogger.com,1999:blog-5740027206976638755.post-11967372922327848922012-03-12T08:03:00.001-07:002012-03-16T06:49:00.456-07:00Alert Dialog<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><b> For showing Alert Dialog in your Activity....</b></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><span style="font-size: large;">import this...</span></span></div><br />
<pre class="brush: csharp">import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: purple; font-family: Monaco;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><br />
</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><span style="font-size: large;">Call this method for showing alert dialog </span></span></div><br />
<pre class="brush: csharp">void showDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Title"); // Set the title displayed in the Dialog.
builder.setMessage("Message"); // Set the message to display.
// Set a listener to be invoked when the neutral button of the dialog is pressed.
builder.setNeutralButton("Ok", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Stop the activity
finish(); // Call this when your activity is done and should be closed. The ActivityResult is
// propagated back to whoever launched you via onActivityResult().
}
});
builder.show(); // Creates a AlertDialog with the arguments supplied to this builder and show()'s the dialog.
}
</pre><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Monaco;"><br />
</span><br />
<span style="font-family: Monaco;"><br />
</span><br />
<span style="color: red; font-family: Monaco; font-size: large;"><b>ScreenShot :</b></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXtm2JtWp_0B0-i4Xt4BwYjH6QIt-rOR-Ti3qtDds3RxZgjza_XHHzXwMjW-v8Og5-lf4hOdij6-VSEYECT4-61XNvnPaE2HnGf6w0VLE0cVZ1FiTxjZ1v_qBNI5qSKvyu1zctrWPG-1s/s1600/alert+dialog.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXtm2JtWp_0B0-i4Xt4BwYjH6QIt-rOR-Ti3qtDds3RxZgjza_XHHzXwMjW-v8Og5-lf4hOdij6-VSEYECT4-61XNvnPaE2HnGf6w0VLE0cVZ1FiTxjZ1v_qBNI5qSKvyu1zctrWPG-1s/s320/alert+dialog.JPG" width="213" /></a></div><span style="font-family: Monaco;"><br />
</span></div><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: #7f0055; font-family: Monaco;"><br />
</span></div></div>Chirag Gabanihttp://www.blogger.com/profile/12507584924560203937noreply@blogger.com0