本文整理匯總了Java中org.appcelerator.titanium.TiApplication.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java TiApplication.getInstance方法的具體用法?Java TiApplication.getInstance怎麽用?Java TiApplication.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.appcelerator.titanium.TiApplication
的用法示例。
在下文中一共展示了TiApplication.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clearSchedule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void clearSchedule() {
TiApplication app = TiApplication.getInstance();
int ntfCount = app.getAppProperties().getInt(PROPERTY_NOTIFICATION_COUNTER, 0);
Log.d(TAG, "Clearing " + ntfCount + " notifications");
if(ntfCount > 0) {
Intent intent = new Intent(app.getApplicationContext(), NotificationPublisher.class);
for(int i = 0; i < ntfCount; i++) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(app.getApplicationContext(), i, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager)app.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
pendingIntent.cancel();
}
app.getAppProperties().setInt(PROPERTY_NOTIFICATION_COUNTER, 0);
}
}
示例2: schedule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public void schedule(long time, HashMap data) {
TiApplication app = TiApplication.getInstance();
int ntfId = app.getAppProperties().getInt(PROPERTY_NOTIFICATION_COUNTER, 0);
Log.d(TAG, "Scheduling notification " + ntfId + " at " + time);
Intent intent = new Intent(app.getApplicationContext(), NotificationPublisher.class);
intent.putExtra(PROPERTY_NOTIFICATION_DATA, data);
PendingIntent pendingIntent = PendingIntent.getBroadcast(app.getApplicationContext(), ntfId, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager)app.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
app.getAppProperties().setInt(PROPERTY_NOTIFICATION_COUNTER, ntfId+1);
}
示例3: onCreate
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
HashMap<String, Object> data = (HashMap)intent.getSerializableExtra(TiGCMModule.NTF_KEY_DATA);
TiGCMModule module = TiGCMModule.getInstance();
TiApplication instance = TiApplication.getInstance();
if(module != null) {
module.fireMessage(data, false);
} else {
KrollDict kdata = new KrollDict(data);
TiApplication.getInstance().getAppProperties().setString(TiGCMModule.PROPERTY_PENDING_DATA, kdata.toString());
Log.d(TAG, "Saving data in props: " + kdata.toString());
}
String pkg = instance.getApplicationContext().getPackageName();
Intent launcherIntent = instance.getApplicationContext().getPackageManager().getLaunchIntentForPackage(pkg);
startActivity(launcherIntent);
finish();
}
示例4: onStart
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Override
protected void onStart() {
super.onStart();
TiGcmModule.logd("GcmLauncherActivity: Starting activity");
KrollDict data = extractIntentData();
if (!appWasRunning) {
TiApplication tiApp = TiApplication.getInstance();
String tiPackageName = tiApp.getPackageName();
String mainClassName = tiApp.getPackageManager().getLaunchIntentForPackage(tiPackageName).getComponent().getClassName();
Intent mainActivityIntent = new Intent();
mainActivityIntent.setClassName(tiPackageName, mainClassName);
mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_SINGLE_TOP);
mainActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(mainActivityIntent);
TiGcmModule.queueDataFromBackground(data);
} else {
TiGcmModule.queueDataFromBackground(data);
this.finish();
}
}
示例5: 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);
}
示例6: initTTS
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public boolean initTTS(
@Kroll.argument(optional = true) String enginepackangename) {
shutdown();
if (enginepackangename != null) {
if (DBG) Log.d(LCAT, "initTTS engine:"+enginepackangename);
if (isPackageInstalled(enginepackangename)) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2) {
tts = new TextToSpeech(TiApplication.getInstance(), this);
tts.setEngineByPackageName(enginepackangename);
} else {
tts = new TextToSpeech(TiApplication.getInstance(), this, enginepackangename);
}
return true;
} else {
if (DBG) Log.d(LCAT, "initTTS engine not found");
return false;
}
} else {
tts = new TextToSpeech(TiApplication.getInstance(), this);
return true;
}
}
示例7: getActionBar
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
private ActionBar getActionBar(){
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return null;
}
try {
ActionBar actionBar = activity.getSupportActionBar();
return actionBar;
} catch (NullPointerException e) {
Log.e(TAG, "ActionBar is null (not found)");
return null;
}
}
示例8: handleSetStatusbarColor
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Sets StatusbarColor for andoid 5.x / materialDesign
* @param obj
*/
private void handleSetStatusbarColor(String color){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
Window win = activity.getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
win.setStatusBarColor(TiConvert.toColor(color));
}
}
示例9: handleSetNavigationBarColor
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* Sets NavigationBarColor for Android 5.x / materialDesign
* @param obj
*/
private void handleSetNavigationBarColor(String color){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return;
}
Window win = activity.getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
win.setNavigationBarColor(TiConvert.toColor(color));
}
}
示例10: getStatusbarHeight
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* returns the height of the Statusbar as absolute pixels
* @return int statusbar height
*/
@Kroll.getProperty @Kroll.method
public int getStatusbarHeight() {
AppCompatActivity activity;
if (window != null){
activity = (AppCompatActivity) window.getActivity();
} else {
TiApplication appContext = TiApplication.getInstance();
activity = (AppCompatActivity) appContext.getCurrentActivity();
}
if (activity == null) {
return 0;
}
int result = 0;
int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = activity.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
示例11: searchDevices
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
@Kroll.method
public boolean searchDevices()
{
Log.d(TAG, "searchDevices called");
//Halilk: if not enabled, enable bluetooth
enableBluetooth();
//Get Current activity//
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
activity.registerReceiver(myReceiver, intentFilter);
bluetoothAdapter.cancelDiscovery(); //cancel if it's already searching
bluetoothAdapter.startDiscovery();
return true;
}
示例12: BluetoothModule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
/**
* @class BluetoothModule
* @constructor
* @return {BluetoothModule} The bluetooth namespace.
*/
public BluetoothModule()
{
super();
TiApplication appContext = TiApplication.getInstance();
Activity currentActivity = appContext.getCurrentActivity();
mContext = currentActivity.getBaseContext();
startService();
}
示例13: getModule
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public static TitaniumCountlyAndroidMessagingModule getModule() {
TitaniumCountlyAndroidMessagingModule module = null;
TiApplication appContext = TiApplication.getInstance();
Activity activity = appContext.getCurrentActivity();
Log.d(LCAT, "Activity:" + activity);
Log.d(LCAT, "lastinstance" + lastInstance);
if ((activity != null) && (lastInstance != null)) {
module = (TitaniumCountlyAndroidMessagingModule)lastInstance.get();
}
return module;
}
開發者ID:dieskim,項目名稱:countly-sdk-appcelerator-titanium-android,代碼行數:12,代碼來源:TitaniumCountlyAndroidMessagingModule.java
示例14: 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();
}
示例15: ExampleView
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public ExampleView(TiViewProxy proxy) {
super(proxy);
String packageName = proxy.getActivity().getPackageName();
Resources resources = proxy.getActivity().getResources();
View progressBarWrapper;
int resId_progressBarHolder = -1;
int resId_progressBar = -1;
resId_progressBarHolder = resources.getIdentifier(
"progressbar_layout", "layout", packageName);
resId_progressBar = resources.getIdentifier("progressbar_default",
"id", packageName);
LayoutInflater inflater = LayoutInflater.from(getActivity());
progressBarWrapper = inflater
.inflate(resId_progressBarHolder, null);
progressBar = (ProgressBar) progressBarWrapper
.findViewById(resId_progressBar);
TiApplication appContext = TiApplication.getInstance();
progressBar
.setIndeterminateDrawable(new SmoothProgressDrawable.Builder(
appContext).sectionsCount(sectionsCount)
.separatorLength(separatorLength).speed(speed)
.mirrorMode(mirrorMode).reversed(reversed)
.color(color).strokeWidth(strokeWidth)
.interpolator(interpolator).build());
setNativeView(progressBarWrapper);
}