Smartphone Usage
I found this great site where you can create your own charts based on the data held against smartphone usage. So I tried it out and have got some expected and some surprising results. Read More...Basics - Adding buttons in Android
Mark, my employer gave me an Android For Beginners development guide which was much easier to follow. However the guide didn't cover the different ways you can achieve the same results.
For example, following the guide, I was writing code in the main.xml to create buttons . . .
<Button android:layout_width="fill_parent"
android:text="Button"
android:id="@+id/button1"
android:layout_height="wrap_content"
></Button>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:text="Button" android:layout_height="wrap_content"
></Button>
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" ></Button>
. . which took a lot of time. Then Mark showed me how I could just easily drag and drop the actual button in the graphical layout.

I Understand the guide was trying to return to absolute basics, in order to explain what the coding means. However not showing any alternative ways to do something so critical to app development was not very helpful.
It just shows you can’t beat having an expert on hand to help you along the way!
Using Market Intents
However in order to use these intents within your app the user also has to have the app with the intent installed on their device. If the user doesn't have the app installed you want to automatically point them to the apps that they require, i.e. open up the Android Market at the right page ready for them to install it. The user can then install the required app and perform a back action to return to your app. This can be achieved with a simple piece of code.
Lets say for example you want to incorporate barcode scanning within your app. You could utilise ZXing. So within the method where you are trying to access the intent (i.e. scan a barcode) you can add code like this:-
1: try
2: {
3: Intent newIntent = new Intent("com.google.zxing.client.android.SCAN");
4: startActivityForResult(newIntent, BARCODE_SCAN );
5: }
6: catch (Exception e)
7: {
8: String zxingUrl = "market://details?id=com.google.zxing.client.android";
9: Intent intent = new Intent(Intent.ACTION_VIEW,
10: Uri.parse(zxingUrl));
11:
12: intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
13: startActivity(intent);
14: }
The FLAG_ACTIVITY_NO_HISTORY value stops the marketplace from being kept on the history stack. so as soon as the user navigates away from it the marketplace is killed and the user will be returned to your app.
Helpful Android information for developers
Check out -
Android Blog Spot - provides project's news, tips and tricks and development examples.




