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


Java TiApplication類代碼示例

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


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

示例1: hasStoragePermissions

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
private boolean hasStoragePermissions() {
if (Build.VERSION.SDK_INT < 23) {
	return true;
}

Context context = TiApplication.getInstance().getApplicationContext();

if (context.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
	return true;
}

return false;
  }
 
開發者ID:prashantsaini1,項目名稱:titanium-android-imagepicker,代碼行數:14,代碼來源:ImagepickerModule.java

示例2: onPostExecute

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Override
protected void onPostExecute(ArrayList<ImageAdapaterArray> items) {
	if (items.size() > 0) {
		totalSelectedImages = 0;
    	
		adapter.clear();
    	adapter.addAll(items);
    	
    	setupMaxCountSize();
    	setTotalCount();
    	
        adapterSet.notifyDataSetChanged();
        
	} else {
		Toast.makeText(TiApplication.getAppCurrentActivity().getApplicationContext(), "No pictures available in your gallery.", Toast.LENGTH_SHORT).show();
		onBackPressed();
	}
}
 
開發者ID:prashantsaini1,項目名稱:titanium-android-imagepicker,代碼行數:19,代碼來源:ImagePickerActivity.java

示例3: start

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Kroll.method
public void start()
{
    setState(STATE_RUNNING);
    // App opens analytics
    ParseAnalytics.trackAppOpenedInBackground(TiApplication.getAppRootOrCurrentActivity().getIntent());
    ParseInstallation.getCurrentInstallation().put("androidId", getAndroidId());
    ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
        public void done(ParseException e) {
            if (e != null) {
                Log.e(TAG, "Installation initialization failed: " + e.getMessage());
            }
            // fire event
            try {
            	JSONObject pnData = new JSONObject();
	pnData.put("objectId", getObjectId());
	pnData.put("installationId", getCurrentInstallationId());
	KrollDict data = new KrollDict(pnData);
             module.fireEvent("installationId", data);
} catch (JSONException e1) {
	Log.e(TAG, "InstallationId event failed: " + e1.getMessage());
}
        }
    });
}
 
開發者ID:gimdongwoo,項目名稱:Titanium-Parse-Android,代碼行數:26,代碼來源:ParseModule.java

示例4: 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;
}
 
開發者ID:prashantsaini1,項目名稱:ti-chrometabs,代碼行數:24,代碼來源:TichrometabsModule.java

示例5: setHtml

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Kroll.method
public void setHtml(String html, @Kroll.argument(optional = true) KrollDict d)
{
	setProperty(TiC.PROPERTY_HTML, html);
	setProperty(OPTIONS_IN_SETHTML, d);

	// If the web view has not been created yet, don't set html here. It will be set in processProperties() when the
	// view is created.
	TiUIView v = peekView();
	if (v != null) {
		if (TiApplication.isUIThread()) {
			((TiUIWebView) v).setHtml(html, d);
		} else {
			getMainHandler().sendEmptyMessage(MSG_SET_HTML);
		}
	}
}
 
開發者ID:chreck,項目名稱:movento-webview,代碼行數:18,代碼來源:WebViewProxy.java

示例6: isHTCSenseDevice

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
private boolean isHTCSenseDevice()
{
	boolean isHTC = false;
	
	FeatureInfo[] features = TiApplication.getInstance().getApplicationContext().getPackageManager().getSystemAvailableFeatures();
	if(features == null) { 
		return isHTC;
	}
	for (FeatureInfo f : features) {
		String fName = f.name;
		if (fName != null) {
			isHTC = fName.contains("com.htc.software.Sense");
			if (isHTC) {
				Log.i(TAG, "Detected com.htc.software.Sense feature "+fName);
				break;
			}
		}
	}
	
	return isHTC;
}
 
開發者ID:chreck,項目名稱:movento-webview,代碼行數:22,代碼來源:TiUIWebView.java

示例7: onMessageReceived

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Override
public void onMessageReceived(String from, Bundle rawData) {
    Log.d(TAG, "Received message from: " + from);
    HashMap<String, Object> data = CttimekogcmModule.bundleToHashMap(rawData);

    boolean forceCreateNotification = false;
    if (data.containsKey("forceCreateNotification")) {
        if (data.get("forceCreateNotification").equals("true")) {
            forceCreateNotification = true;
        }
    }

    try {
        CttimekogcmModule module = CttimekogcmModule.getInstance();
        if(module != null && !forceCreateNotification) {
            if(KrollRuntime.isInitialized() && TiApplication.isCurrentActivityInForeground()) {
                module.fireMessage(data, true);
                return;
            }
        }
    } catch (Exception e) {
        Log.d(TAG, "Couldn't send fireMessage to CttimekogcmModule");
    }

    NotificationPublisher.createNotification(this, data);
}
 
開發者ID:a-voityuk,項目名稱:CTTimekoGCM,代碼行數:27,代碼來源:ListenerService.java

示例8: 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

示例9: 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

示例10: hasPermission

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
/**
 * check, if given permission is currently granted
 * 
 * @param requestedPermission - permission as defined in Manifest
 * @return
 */
@Kroll.method
public boolean hasPermission(@Kroll.argument() String requestedPermission) {
	Log.d(LCAT, "check for granted permission: " + requestedPermission);

	// TODO really depends on Build or Platform???
	if (Build.VERSION.SDK_INT < 23) {
		return true;
	}

	Context ctx = TiApplication.getInstance().getApplicationContext(); 
	if (ContextCompat.checkSelfPermission(ctx,
			requestedPermission) != PackageManager.PERMISSION_GRANTED) {
		return false;
	}
	return true;
}
 
開發者ID:stgrosshh,項目名稱:tipermissions,代碼行數:23,代碼來源:TipermissionsModule.java

示例11: parseBootIntent

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
public void parseBootIntent() {
	try {
		Bundle extras = TiApplication.getAppRootOrCurrentActivity().getIntent().getExtras();
		String notification = "";

		if (extras != null) {
			notification = extras.getString("data");
			for (String key : extras.keySet()) {
                		Object value = extras.get(key);
                		Log.d(LCAT, "Key: " + key + " Value: " + value);
            		}
		}

		if (notification != null && !notification.isEmpty()) {
			sendMessage(notification, true);
		} else {
			Log.d(LCAT, "No notification in Intent");
		}
	} catch (Exception ex) {
		Log.e(LCAT, "parseBootIntent" + ex);
	}
}
 
開發者ID:caffeinalab,項目名稱:ti.goosh,代碼行數:23,代碼來源:TiGooshModule.java

示例12: 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

示例13: unregisterForPushNotifications

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Kroll.method
public void unregisterForPushNotifications() {
	final String senderId = getSenderId();
	final Context context = TiApplication.getInstance().getApplicationContext();

	new AsyncTask<Void, Void, Void>() {
		@Override
		protected Void doInBackground(Void... params) {
			try {
				InstanceID.getInstance(context).deleteToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE);
				Log.d(LCAT, "delete instanceid succeeded");
			} catch (final IOException e) {
				Log.e(LCAT, "remove token failed - error: " + e.getMessage());
			}
			return null;
		}
	}.execute();
}
 
開發者ID:caffeinalab,項目名稱:ti.goosh,代碼行數:19,代碼來源:TiGooshModule.java

示例14: 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();
  }
}
 
開發者ID:E2010,項目名稱:android-parse-module-titanium-3-5,代碼行數:19,代碼來源:ParseSingleton.java

示例15: onAppCreate

import org.appcelerator.titanium.TiApplication; //導入依賴的package包/類
@Kroll.onAppCreate
public static void onAppCreate(TiApplication app)
{
	Log.d(LCAT, "inside onAppCreate");
	
	// put module init code that needs to run when the application is created
	// Store a reference to the parse singleton now that the app is ready
	parseSingleton = ParseSingleton.Instance();

	// Obtain the application and client keys from the tiapp.xml file.
	// It must be stored there because of the way Android applications work,
	// we can't initialize the module during runtime because the application is
	// started when a push notification is received
	String propertyAppId = app.getAppProperties().getString(ParseSingleton.PROPERTY_APP_ID, "");
	String propertyClientKey = app.getAppProperties().getString(ParseSingleton.PROPERTY_CLIENT_KEY, "");
	String propertyServerUrl = app.getAppProperties().getString(ParseSingleton.PROPERTY_SERVER_URL, "");

	// Invoke the Parse SDK Initialize method
	//parseSingleton.InitializeParse(propertyAppId, propertyClientKey, app);
	parseSingleton.InitializeParseWithConfig(propertyAppId, propertyClientKey, propertyServerUrl, app);
}
 
開發者ID:E2010,項目名稱:android-parse-module-titanium-3-5,代碼行數:22,代碼來源:AndroidTitaniumParseModule.java


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