當前位置: 首頁>>代碼示例>>Java>>正文


Java TiApplication.getAppRootOrCurrentActivity方法代碼示例

本文整理匯總了Java中org.appcelerator.titanium.TiApplication.getAppRootOrCurrentActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java TiApplication.getAppRootOrCurrentActivity方法的具體用法?Java TiApplication.getAppRootOrCurrentActivity怎麽用?Java TiApplication.getAppRootOrCurrentActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.appcelerator.titanium.TiApplication的用法示例。


在下文中一共展示了TiApplication.getAppRootOrCurrentActivity方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerForPushNotifications

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void registerForPushNotifications(HashMap options) {
	Activity activity = TiApplication.getAppRootOrCurrentActivity();

	if (false == options.containsKey("callback")) {
		Log.e(LCAT, "You have to specify a callback attribute when calling registerForPushNotifications");
		return;
	}

	messageCallback = (KrollFunction)options.get("callback");

	successCallback = options.containsKey("success") ? (KrollFunction)options.get("success") : null;
	errorCallback = options.containsKey("error") ? (KrollFunction)options.get("error") : null;

	parseBootIntent();

	if (checkPlayServices()) {
		activity.startService( new Intent(activity, RegistrationIntentService.class) );
	}
}
 
開發者ID:caffeinalab,項目名稱:ti.goosh,代碼行數:21,代碼來源:TiGooshModule.java

示例2: DownloaderModule

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public DownloaderModule() {
	super("Downloader");
	downloader = new ProgressiveDownloader(TiApplication.getAppRootOrCurrentActivity());
	downloader.setMaximumSimultaneousDownloads(2);
	downloader.DownloadProgress.addListener(new ProgressListener());
	downloader.DownloadPaused.addListener(new PausedListener());
	downloader.DownloadFailed.addListener(new FailedListener());
	downloader.DownloadCompleted.addListener(new CompletedListener());
	downloader.DownloadCancelled.addListener(new CancelledListener());
	downloader.DownloadStarted.addListener(new StartedListener());
	downloader.DownloadBatchPaused.addListener(new BatchPausedListener());
	downloader.DownloadBatchFailed.addListener(new BatchFailedListener());
	downloader.DownloadBatchCompleted.addListener(new BatchCompletedListener());
	downloader.DownloadBatchCancelled.addListener(new BatchCancelledListener());
	
	this.self = this;
}
 
開發者ID:kcwdevllc,項目名稱:android-background-downloader,代碼行數:18,代碼來源:DownloaderModule.java

示例3: checkPlayServices

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
private boolean checkPlayServices() {
	Activity activity = TiApplication.getAppRootOrCurrentActivity();

	GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
	int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
	if (resultCode != ConnectionResult.SUCCESS) {
		if (apiAvailability.isUserResolvableError(resultCode)) {
			apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show();
		} else {
			Log.e(LCAT, "This device is not supported.");
		}
		return false;
	}
	return true;
}
 
開發者ID:caffeinalab,項目名稱:ti.goosh,代碼行數:16,代碼來源:TiGooshModule.java

示例4: onCreate

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
	try {
		Log.d(LCAT, "started");
		super.onCreate(savedInstanceState);
		finish();

		TiGooshModule module = TiGooshModule.getModule();
		Context context = getApplicationContext();
		String notification = getIntent().getStringExtra(TiGooshModule.INTENT_EXTRA);

		Intent launcherIntent;

		if (TiApplication.getAppRootOrCurrentActivity() == null) {
			launcherIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
			launcherIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
		} else {
			launcherIntent = TiApplication.getAppRootOrCurrentActivity().getIntent();
			if (module != null) {
				TiGooshModule.getModule().sendMessage(notification, true);
			}
		}

		launcherIntent.putExtra(TiGooshModule.INTENT_EXTRA, notification);
		startActivity(launcherIntent);
	} catch (Exception e) {
		// noop
	} finally {
		finish();
	}
}
 
開發者ID:caffeinalab,項目名稱:ti.goosh,代碼行數:32,代碼來源:PushHandlerActivity.java

示例5: saveAuthToken

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
 * Persists an authorization token for later use.
 * @param authToken
 */
public static void saveAuthToken(String authToken) {
	Activity activity = TiApplication.getAppRootOrCurrentActivity();
	final SharedPreferences prefs = activity.getSharedPreferences(Constants.PREFS_FILE_NAME, 0);
    final SharedPreferences.Editor editor = prefs.edit();
    if (authToken == null) {
    	editor.remove(Constants.PREFS_KEY_AUTH_TOKEN);
    }
    else {
    	editor.putString(Constants.PREFS_KEY_AUTH_TOKEN, authToken);
    }
    editor.commit();
    Constants.setAuthToken(authToken);
}
 
開發者ID:appcelerator-archive,項目名稱:ti.box,代碼行數:18,代碼來源:Util.java

示例6: getAuthToken

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public static String getAuthToken() {
	if (AUTH_TOKEN == null) {
		Activity activity = TiApplication.getAppRootOrCurrentActivity();
		final SharedPreferences prefs = activity.getSharedPreferences(Constants.PREFS_FILE_NAME, 0);
		AUTH_TOKEN = prefs.getString(Constants.PREFS_KEY_AUTH_TOKEN, null);
	}
	return AUTH_TOKEN;
}
 
開發者ID:appcelerator-archive,項目名稱:ti.box,代碼行數:9,代碼來源:Constants.java

示例7: TibeaconModule

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public TibeaconModule () {
	super();
	TiApplication appContext = TiApplication.getInstance();
	activity = appContext.getAppRootOrCurrentActivity();
	Log.i("LOG","act:" + activity);
	Log.i("LOG","act:" + appContext.getAppCurrentActivity());
	Log.i("LOG","act:" +  appContext.getCurrentActivity());
	context = appContext.getBaseContext();
}
 
開發者ID:renegaat,項目名稱:LBi_dmexco_android,代碼行數:10,代碼來源:TibeaconModule.java

示例8: getPhoneNumber

import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public String getPhoneNumber()
{
	Activity cn = TiApplication.getAppRootOrCurrentActivity();

	TelephonyManager tm = (TelephonyManager) cn.getSystemService(Context.TELEPHONY_SERVICE);
	String phone = tm.getLine1Number();

	return phone;
}
 
開發者ID:adebard,項目名稱:titanium-android-telephonymanager,代碼行數:11,代碼來源:TelephonymanagerModule.java


注:本文中的org.appcelerator.titanium.TiApplication.getAppRootOrCurrentActivity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。