本文整理匯總了Java中org.appcelerator.titanium.TiApplication.getApplicationContext方法的典型用法代碼示例。如果您正苦於以下問題:Java TiApplication.getApplicationContext方法的具體用法?Java TiApplication.getApplicationContext怎麽用?Java TiApplication.getApplicationContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.appcelerator.titanium.TiApplication
的用法示例。
在下文中一共展示了TiApplication.getApplicationContext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
}
}
示例4: InitializeParse
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public void InitializeParse(String appId, String clientKey, TiApplication application) {
Context appContext = application.getApplicationContext();
if (appContext == null) {
Log.e(TAG, "Application context is null, cannot continue...");
return;
}
else if (appId != null && appId.isEmpty()) {
Log.e(TAG, "Application key is required! Parse has NOT been initialized.");
return;
}
else if (clientKey != null && clientKey.isEmpty()) {
Log.e(TAG, "Client key is required! Parse has NOT been initialized.");
return;
}
if (!initialized) {
Log.d(TAG, "Initializing with: '" + appId + "' and '" + clientKey + "'.");
Parse.initialize(appContext, appId, clientKey);
initialized = true;
}
else
{
Log.e(TAG, "Parse has already been initialized!");
}
}
示例5: InitializeParseWithConfig
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public void InitializeParseWithConfig(String appId, String clientKey, String serverUrl, TiApplication application) {
Context appContext = application.getApplicationContext();
if (appContext == null) {
Log.e(TAG, "Application context is null, cannot continue...");
return;
} else if (appId != null && appId.isEmpty()) {
Log.e(TAG, "Application key is required! Parse has NOT been initialized.");
return;
} else if (serverUrl != null && serverUrl.isEmpty()) {
Log.e(TAG, "Server Url is required! Parse has NOT been initialized.");
return;
}
if (!initialized) {
Log.d(TAG, "Initializing with: '" + appId + "' and '" + serverUrl + "'.");
Parse.initialize(new Parse.Configuration.Builder(appContext)
.applicationId(appId)
.clientKey(null)
.server(serverUrl)
.build());
initialized = true;
}
else
{
Log.e(TAG, "Parse has already been initialized!");
}
}
示例6: NotificationProxy
import org.appcelerator.titanium.TiApplication; //導入方法依賴的package包/類
public NotificationProxy() {
super();
TiApplication app = TiApplication.getInstance();
mNotifyManager = (NotificationManager) app.getSystemService(Activity.NOTIFICATION_SERVICE);
mBuilder = new NotificationCompat.Builder(app.getApplicationContext());
makeOngoingProgress(0, true); // make progress bar indeterminate when 1st notify
}