当前位置: 首页>>代码示例>>Java>>正文


Java Kroll.method方法代码示例

本文整理汇总了Java中org.appcelerator.kroll.annotations.Kroll.method方法的典型用法代码示例。如果您正苦于以下问题:Java Kroll.method方法的具体用法?Java Kroll.method怎么用?Java Kroll.method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.appcelerator.kroll.annotations.Kroll的用法示例。


在下文中一共展示了Kroll.method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的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

示例2: openURL

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的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

示例3: unregisterForPushNotifications

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的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

示例4: setHtml

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的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

示例5: requestPermission

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
/**
 * Request a permission and optionally register a callback for the current activity
 * 
 * @param requestedPermission permission as defined in Manifest
 * @param permissionCallback function called with result of permission prompt
 * @param requestCode - 8 Bit value to associate callback with request - if none is provided a system generated will used
 * @return true in case of valid request, false if requested permission is not a valid one
 */
@Kroll.method
public boolean requestPermission(String requestedPermission,
		@Kroll.argument(optional = true) KrollFunction permissionCallback,
		@Kroll.argument(optional = true) Integer requestCode) {

	Log.d(LCAT, "Requesting permission: " + requestedPermission);

	if (!isValidPermissionString(requestedPermission)) {
		Log.e(LCAT, "Requested permission is not supported :"
				+ requestedPermission);
		return false;
	}

	return handleRequest(new String[]{requestedPermission}, requestCode, permissionCallback);

}
 
开发者ID:stgrosshh,项目名称:tipermissions,代码行数:25,代码来源:TipermissionsModule.java

示例6: hasPermission

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的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

示例7: getAndroidUUID

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public synchronized String getAndroidUUID() {
    if (uniqueID == null) {
        SharedPreferences sharedPrefs = TiApplication.getInstance().getApplicationContext().getSharedPreferences(
                PREF_UNIQUE_ID, Context.MODE_PRIVATE);
        uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
        if (uniqueID == null) {
            uniqueID = UUID.randomUUID().toString();
            Editor editor = sharedPrefs.edit();
            editor.putString(PREF_UNIQUE_ID, uniqueID);
            editor.commit();
        }
    }
    return uniqueID;
}
 
开发者ID:grazianogrespan,项目名称:Ti.AndroidID,代码行数:16,代码来源:AndroidDeviceIdModule.java

示例8: getImage

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public TiBlob getImage(String filePath) {
	filePath = filePath.replaceFirst("file://", "");
	
       if (null != filePath) {
           return TiBlob.blobFromImage( BitmapFactory.decodeFile(filePath) );
       }
       
       Log.e(Defaults.LCAT, "File path missing");
       return null;
   }
 
开发者ID:prashantsaini1,项目名称:titanium-android-imagepicker,代码行数:12,代码来源:ImagepickerModule.java

示例9: authenticate

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public void authenticate(@Kroll.argument String sessionToken) {
    ParseUser.becomeInBackground(sessionToken, new LogInCallback() {
        public void done(ParseUser user, ParseException e) {
            if (user != null) {
                // Hooray! The user is logged in.
            } else {
                // Signup failed. Look at the ParseException to see what happened.
            }
        }
    });
}
 
开发者ID:gimdongwoo,项目名称:Titanium-Parse-Android,代码行数:13,代码来源:ParseModule.java

示例10: setRequestHeaders

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public void setRequestHeaders(HashMap d)
{
	TiUIWebView currWebView = getWebView();
 		if (currWebView != null) {
 			if (TiApplication.isUIThread()) {
 				currWebView.setRequestHeaders(d);
 			} else {
 				//
 				Message message = getMainHandler().obtainMessage(MSG_SET_HEADER);
 				message.obj = d;
 				message.sendToTarget();
 			}
 		}
 	}
 
开发者ID:chreck,项目名称:movento-webview,代码行数:16,代码来源:WebViewProxy.java

示例11: getHtml

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method @Kroll.getProperty
public String getHtml()
{
	if (!hasProperty(TiC.PROPERTY_HTML)) {
		return getWebView().getJSValue("document.documentElement.outerHTML");
	}
	return (String) getProperty(TiC.PROPERTY_HTML);
}
 
开发者ID:chreck,项目名称:movento-webview,代码行数:9,代码来源:WebViewProxy.java

示例12: setBasicAuthentication

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public void setBasicAuthentication(String username, String password)
{
	if (peekView() == null) {
		// if the view is null, we cache the username/password
		fusername = username;
		fpassword = password;
		return;
	}
	clearBasicAuthentication();
	getWebView().setBasicAuthentication(username, password);

}
 
开发者ID:chreck,项目名称:movento-webview,代码行数:14,代码来源:WebViewProxy.java

示例13: areNotificationsEnabled

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public boolean areNotificationsEnabled() {
	try{
		return NotificationManagerCompat.from(TiApplication.getInstance().getApplicationContext()).areNotificationsEnabled();
	}catch(Exception ex){
		return false;
	}
	
}
 
开发者ID:caffeinalab,项目名称:ti.goosh,代码行数:10,代码来源:TiGooshModule.java

示例14: canGoBack

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public boolean canGoBack()
{
	if (peekView() != null) {
		if (TiApplication.isUIThread()) {
			return getWebView().canGoBack();
		} else {
			return (Boolean) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_CAN_GO_BACK));
		}
	}
	return false;
}
 
开发者ID:chreck,项目名称:movento-webview,代码行数:13,代码来源:WebViewProxy.java

示例15: canGoForward

import org.appcelerator.kroll.annotations.Kroll; //导入方法依赖的package包/类
@Kroll.method
public boolean canGoForward()
{
	if (peekView() != null) {
		if (TiApplication.isUIThread()) {
			return getWebView().canGoForward();
		} else {
			return (Boolean) TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_CAN_GO_FORWARD));
		}
	}
	return false;
}
 
开发者ID:chreck,项目名称:movento-webview,代码行数:13,代码来源:WebViewProxy.java


注:本文中的org.appcelerator.kroll.annotations.Kroll.method方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。