本文整理匯總了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) );
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}