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


Java TiApplication.getInstance方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:a-voityuk,項目名稱:CTTimekoGCM,代碼行數:21,代碼來源:CttimekogcmModule.java

示例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);
}
 
開發者ID:a-voityuk,項目名稱:CTTimekoGCM,代碼行數:17,代碼來源:CttimekogcmModule.java

示例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();
}
 
開發者ID:hyperlab,項目名稱:TiAndroidNotifications,代碼行數:26,代碼來源:NotificationActivity.java

示例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();
    }
}
 
開發者ID:GregPerez83,項目名稱:ti-gcm,代碼行數:26,代碼來源:GcmLauncherActivity.java

示例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);
}
 
開發者ID:PDF417,項目名稱:pdf417-titanium,代碼行數:23,代碼來源:Pdf417pluginModule.java

示例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;
	}
}
 
開發者ID:isis,項目名稱:TTS-Module,代碼行數:24,代碼來源:TtsModule.java

示例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;
	}

}
 
開發者ID:ricardoalcocer,項目名稱:actionbarextras,代碼行數:24,代碼來源:ActionbarextrasModule.java

示例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));
	}
}
 
開發者ID:ricardoalcocer,項目名稱:actionbarextras,代碼行數:24,代碼來源:ActionbarextrasModule.java

示例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));
	}
}
 
開發者ID:ricardoalcocer,項目名稱:actionbarextras,代碼行數:24,代碼來源:ActionbarextrasModule.java

示例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;
}
 
開發者ID:ricardoalcocer,項目名稱:actionbarextras,代碼行數:27,代碼來源:ActionbarextrasModule.java

示例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;
}
 
開發者ID:halilkabaca,項目名稱:NovarumBluetooth,代碼行數:20,代碼來源:NovarumbluetoothModule.java

示例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();
}
 
開發者ID:eyesore,項目名稱:appc-android-bluetooth,代碼行數:14,代碼來源:BluetoothModule.java

示例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();
}
 
開發者ID:renegaat,項目名稱:LBi_dmexco_android,代碼行數:10,代碼來源:TibeaconModule.java

示例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);

}
 
開發者ID:artanisdesign,項目名稱:ti-smoothprogressbar,代碼行數:36,代碼來源:SmoothProgressBarProxy.java


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