Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-14291

Android: Support for PackageManager and queryIntentActivities

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: Release 3.1.1
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      Ti SDK 3.1.1.GA

      Description

      At the moment, there is no way to figure out which apps and intents is available on the users device.

      So we need to guess, or do try catch logic, like this:

       
      try {
      	var intent = Ti.Android.createIntent({
      		action : Ti.Android.ACTION_SEND,
      		packageName : "com.twitter.android",
      		className : "com.twitter.android.PostActivity",
      		flags : Ti.Android.FLAG_ACTIVITY_NEW_TASK,
      		type : "text/plain"
      	});
      	
      	if (options.text) {
      		intent.putExtra(Ti.Android.EXTRA_TEXT, options.text);
      	}
      	Ti.Android.currentActivity.startActivity(intent);
       
      } catch(e){
      	// Fallback - if app is not installed
      	// do something
      }
      

      What we need is access to Android Package Manager. This way we can loop through the installed applications, and figure out what is available, instead of guessing.

      I could do something like this: http://stackoverflow.com/questions/6827407/how-to-customize-share-intent-in-android/9229654#9229654

      Proposal:

      // test
      var bool = Ti.Android.isPackageNameSupported("com.twitter.android");
       
      // get all apps installed
      var mainIntent = Ti.Android.createIntent({
      	action : Ti.Android.ACTION_SEND
      });
      mainIntent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
      var packageManager = Ti.Android.getPackageManager();
      var applist = packageManager.queryIntentActivities( mainIntent, 0);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                viezel Mads Moller
              • Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration