Sunday, October 6, 2013

Android-Adding Activity Categories

Adding Activity Categories

Adding Categories

You can group your activities into categories by using the element in the intent filter. Suppose you have added the following element to the AndroidManifest.xml file:

package=”net.learn2develop.Intents”
android:versionCode=”1”
android:versionName=”1.0”>
android:label=”@string/app_name”>
android:label=”@string/app_name”>

Adding Activity Categories

In this case, the following code will invoke the MyBrowerActivity activity:
Intent i = new
Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(“http://www.amazon.com”));
i.addCategory(“net.learn2develop.Apps”);
startActivity(i);

Adding Activity Categories

You add the category to the Intent object using the addCategory() method. If you omit the addCategory() statement, the preceding code will still invoke the MyBrowerActivity activity because it will still match the default category “android.intent.category.DEFAULT”. However, if you specify a category that does not match the category defined in the intent filter, it will not work:
Intent i = new
Intent(“net.learn2develop.MyBrowser”,
Uri.parse(“http://www.amazon.com”));
//---this category does not match any in the intent-filter---
i.addCategory(“net.learn2develop.OtherApps”);
startActivity(i);

Adding Activity Categories

The preceding category (“net.learn2develop.OtherApps”) does not match any in the intent filter, so a run-time exception will be raised.
If you add the preceding category in the intent filter of MyBrowerActivity, then the preceding code will work:

Adding Activity Categories

You can add multiple categories to an Intent object; for example, the following statements add the “net.learn2develop.SomeOtherApps” category to the Intent object:
Intent i = new Intent(“net.learn2develop.MyBrowser”,
Uri.parse(“http://www.amazon.com”));
i.addCategory(“net.learn2develop.OtherApps”);
i.addCategory(“net.learn2develop.SomeOtherApps”);
startActivity(i);


Upload UIImage as base64 String

Upload UIImage as Base64 String (Upload UIImage as string) //Select Pic From Camera or Gallery       @objc func btnPro...