本文整理匯總了Java中org.appcelerator.titanium.TiApplication.getAppCurrentActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java TiApplication.getAppCurrentActivity方法的具體用法?Java TiApplication.getAppCurrentActivity怎麽用?Java TiApplication.getAppCurrentActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.appcelerator.titanium.TiApplication
的用法示例。
在下文中一共展示了TiApplication.getAppCurrentActivity方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: openURL
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public boolean openURL(KrollDict options) {
if ( (options != null) && options.containsKeyAndNotNull(Params.URL)) {
Context context = TiApplication.getAppCurrentActivity();
List<ResolveInfo> browsersList = Utils.allBrowsers(context);
if (!browsersList.isEmpty()) {
List<String> customTabBrowsers = getCustomTabBrowsers(context, browsersList);
// show supported browsers list or open directly if only 1 supported browser is available
openCustomTab(context, customTabBrowsers, options);
return true;
} else {
Log.i(Params.LCAT, "No browsers available in this device.");
return false;
}
}
Log.i(Params.LCAT, "Check your paramters. URL parameter is mandatory.");
return false;
}
示例2: EnablePush
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public static void EnablePush(TiApplication app) {
Context appContext = app.getApplicationContext();
Activity appActivity = app.getAppCurrentActivity();
if (appContext == null) {
Log.e(TAG, "Application context is null, can't initialize Parse");
return;
}
else if (appActivity == null) {
Log.e(TAG, "Application activity is null, can't initialize Parse");
return;
}
else {
//PushService.setDefaultPushCallback(appContext, appActivity.getClass());
ParseAnalytics.trackAppOpened(appActivity.getIntent());
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
示例3: scan
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
@SuppressWarnings({ "rawtypes", "unchecked" })
public void scan(@Kroll.argument(optional = false) HashMap args) {
Log.d(LCAT, "scan called with arguments:" + args);
TiApplication appContext = TiApplication.getInstance();
Intent intent = new Intent(appContext, Pdf417ScanActivity.class);
Pdf417MobiSettings sett = new Pdf417MobiSettings();
// Parse scan arguments into settings and intent extras
parseArguments(args, sett, intent);
// put settings as intent extra
intent.putExtra(BaseBarcodeActivity.EXTRAS_SETTINGS, sett);
Activity activity = TiApplication.getAppCurrentActivity();
TiActivitySupport activitySupport = (TiActivitySupport) activity;
final int resultCode = activitySupport.getUniqueResultCode();
activitySupport.launchActivityForResult(intent, resultCode, this);
}
示例4: signin
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void signin(KrollDict props)
{
if (props.containsKey("success")) {
successCallback = (KrollFunction) props.get("success");
}
if (props.containsKey("error")) {
errorCallback = (KrollFunction) props.get("error");
}
String[] accountTypes = new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE };
Intent intent = AccountPicker.newChooseAccountIntent(null, null,
accountTypes, false, null, null, null, null);
Activity activity = TiApplication.getAppCurrentActivity();
TiActivitySupport support = (TiActivitySupport) activity;
requestCode = support.getUniqueResultCode();
support.launchActivityForResult(intent, requestCode, this);
}
示例5: handleRequest
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
private boolean handleRequest(String[] permissions, Integer requestCode, KrollFunction permissionCallback) {
Activity activity = TiApplication.getAppCurrentActivity();
if (!(activity instanceof TiBaseActivity)) {
Log.w(LCAT, "Requesting permission from non-Titanium activity - not supported");
return false;
}
TiBaseActivity currentActivity = (TiBaseActivity) activity;
// Do we need a callback and request code in any case?
if (requestCode == null) {
Log.d(LCAT, "No request code given - Ti Permissions module will generate one");
requestCode = currentActivity.getUniqueResultCode();
}
// register callback in current activity
// TODO what is the exact purpose of the context? We should provide the Activity's Proxy, not the module object
KrollObject context = currentActivity.getActivityProxy().getKrollObject();
Log.d(LCAT, "Registering callback");
currentActivity.registerPermissionRequestCallback(requestCode,
permissionCallback, context,permissions);
Log.d(LCAT, "Calling permission request");
ActivityCompat.requestPermissions(activity, permissions, requestCode);
return true;
}
示例6: handleRecoverableException
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public void handleRecoverableException(Intent recoveryIntent) {
Logger.getLogger(TAG).info("Launchng recoverable intent.");
// Use the intent in a custom dialog or just startActivityForResult.
Activity activity = TiApplication.getAppCurrentActivity();
TiActivitySupport support = (TiActivitySupport) activity;
recoveryRequestCode = support.getUniqueResultCode();
support.launchActivityForResult(recoveryIntent, recoveryRequestCode,
this);
}
示例7: handleGooglePlayException
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public void handleGooglePlayException(
GooglePlayServicesAvailabilityException playEx) {
// Use the dialog to present to the user.
Activity activity = TiApplication.getAppCurrentActivity();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
playEx.getConnectionStatusCode(), activity, requestCode);
dialog.show();
}
示例8: getUserToken
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
private void getUserToken() {
if (mEmail == null) {
handleError(NO_EMAIL);
} else {
String scopeStr = TextUtils.join(" ", mScopes);
FetchUserTokenTask task = new FetchUserTokenTask(TiApplication.getAppCurrentActivity(),
mEmail, scopeStr, mServerId);
task.execute();
}
}
示例9: createCustomGallery
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Kroll.method
public void createCustomGallery(KrollDict options) {
if ( (options != null) && options.containsKeyAndNotNull(Defaults.Params.IMAGES) ) {
Object[] imageArray = (Object []) options.get(Defaults.Params.IMAGES);
int size = imageArray.length;
if (size != 0) {
ArrayList<ImageViewerInfo> imagesInfo = new ArrayList<ImageViewerInfo>();
for (int i=0; i<size; i++) {
Object o = imageArray[i];
KrollDict info = new KrollDict((HashMap<String, Object>) o);
if ( (info != null) && info.containsKeyAndNotNull(Defaults.Params.IMAGE_PATH) ) {
String path = info.getString(Defaults.Params.IMAGE_PATH);
String title = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE) ? info.getString(Defaults.Params.IMAGE_TITLE) : "";
String titleColor = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE_COLOR) ? info.getString(Defaults.Params.IMAGE_TITLE_COLOR) : Defaults.IMAGE_TITLE_COLOR;
String titleBgColor = info.containsKeyAndNotNull(Defaults.Params.IMAGE_TITLE_BACKGROUND_COLOR) ? info.getString(Defaults.Params.IMAGE_TITLE_BACKGROUND_COLOR) : Defaults.IMAGE_TITLE_BACKGROUND_COLOR;
imagesInfo.add(new ImageViewerInfo(path, title, titleColor, titleBgColor));
}
}
if (imagesInfo.size() > 0) {
Activity activity = TiApplication.getAppCurrentActivity();
Intent intent = new Intent(activity, ImageViewerActivity.class);
intent = prepareExtrasForIntent(intent, options, false);
intent.putParcelableArrayListExtra(Defaults.Params.IMAGES, imagesInfo);
activity.startActivity(intent);
}
} else {
Log.e(Defaults.LCAT, "No images passed.");
}
} else {
Log.e(Defaults.LCAT, "No options passed.");
}
}
示例10: GcmLauncherActivity
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public GcmLauncherActivity() {
super();
appWasRunning = TiApplication.getAppCurrentActivity() != null;
}
示例11: initializeCrittercism
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void initializeCrittercism(KrollDict dict) {
Log.d(TAG, "Crittercism Init called");
currentActivity = TiApplication.getAppCurrentActivity();
initCrittercism(dict);
}