Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24050] Android: Be able to open particular application's system settings.

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionDone
Resolution Date2018-01-20T21:05:24.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterShuo Liang
AssigneeUnknown
Created2016-10-19T00:25:22.000+0000
Updated2018-08-06T17:34:46.000+0000

Description

Comments

  1. Chee Kiat Ng 2016-10-19

    Try hyperloop?
  2. Hans Knöchel 2016-10-19

    Hyperloop example (PoC):
       var Intent = require('android.content.Intent');
       var Activity = require('android.app.Activity');
       var Uri = require("android.net.Uri");
       var Settings = require("android.provider.Settings");
        
       var win = Ti.UI.createWindow({
           backgroundColor: "white"
       });
        
       var btn = Ti.UI.createButton({
           title: "Open Application Settings"
       });
        
       btn.addEventListener("click", openIntent);
        
       win.add(btn);
       win.open();
        
       function openIntent() {
           var activity = new Activity(Ti.Android.currentActivity);
       
           var intent = Ti.Android.createIntent();
           var nativeIntent = new Intent(intent);
       
           nativeIntent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
           nativeIntent.addCategory(Intent.CATEGORY_DEFAULT);
           nativeIntent.setData(Uri.parse("package:" + activity.getPackageName()));
           nativeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
           nativeIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
           nativeIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
           
           activity.startActivity(nativeIntent);
       }
       
  3. Hans Knöchel 2016-10-20

    You could try activity.getPackageName() to get it from the native activity, updated the example.
  4. Hans Knöchel 2016-10-20

    The context is nothing else but the activity, so you can just use the casted activity and get it from there (var activity = new Activity(Ti.Android.currentActivity);). See the [android.content.Context](https://developer.android.com/reference/android/content/Context.html) class that is the super class of all activities.
  5. Hans Knöchel 2018-01-20

    Question answered last year, resolving now.
  6. Eric Merriman 2018-08-06

    Closed as completed. If this is in error, please reopen.

JSON Source