本文整理汇总了Java中com.codename1.impl.android.IntentResultListener类的典型用法代码示例。如果您正苦于以下问题:Java IntentResultListener类的具体用法?Java IntentResultListener怎么用?Java IntentResultListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntentResultListener类属于com.codename1.impl.android包,在下文中一共展示了IntentResultListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import com.codename1.impl.android.IntentResultListener; //导入依赖的package包/类
public void scan() {
result = ZXingNativeCalls.PENDING;
com.codename1.impl.android.CodenameOneActivity ctx = (com.codename1.impl.android.CodenameOneActivity)Zxing.getContext();
android.content.Intent intent = new android.content.Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
ctx.setIntentResultListener(new IntentResultListener() {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if (resultCode == com.codename1.impl.android.CodenameOneActivity.RESULT_OK) {
contents = data.getStringExtra("SCAN_RESULT");
format = data.getStringExtra("SCAN_RESULT_FORMAT");
result = ZXingNativeCalls.OK;
} else if (resultCode == com.codename1.impl.android.CodenameOneActivity.RESULT_CANCELED) {
// Handle cancel
result = ZXingNativeCalls.ERROR;
}
}
}
});
ctx.startActivityForResult(intent, 0);
}
示例2: askPublishPermissions
import com.codename1.impl.android.IntentResultListener; //导入依赖的package包/类
public void askPublishPermissions(final LoginCallback cb) {
if (AndroidNativeUtil.getActivity() == null) {
throw new RuntimeException("Cannot ask for publish permissions when running in the background.");
}
if (loginLock) {
return;
}
loginLock = true;
LoginManager login = LoginManager.getInstance();
final CallbackManager mCallbackManager = CallbackManager.Factory.create();
final CodenameOneActivity activity = (CodenameOneActivity) AndroidNativeUtil.getActivity();
activity.setIntentResultListener(new IntentResultListener() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
activity.restoreIntentResultListener();
}
});
login.registerCallback(mCallbackManager, new FBCallback(cb));
login.logInWithPublishPermissions(activity, PUBLISH_PERMISSIONS);
}
示例3: onConnectionFailed
import com.codename1.impl.android.IntentResultListener; //导入依赖的package包/类
public void onConnectionFailed(final ConnectionResult cr) {
if (AndroidNativeUtil.getActivity() == null) {
return;
}
final CodenameOneActivity main = (CodenameOneActivity) AndroidNativeUtil.getActivity();
if (!mIntentInProgress && cr.hasResolution()) {
try {
mIntentInProgress = true;
main.startIntentSenderForResult(cr.getResolution().getIntentSender(),
0, null, 0, 0, 0);
main.setIntentResultListener(new com.codename1.impl.android.IntentResultListener() {
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data) {
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
main.restoreIntentResultListener();
}
});
} catch (SendIntentException e) {
// The intent was canceled before it was sent. Return to the default
// state and attempt to connect to get an updated ConnectionResult.
mIntentInProgress = false;
mGoogleApiClient.connect();
}
return;
}
if (callback != null) {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
callback.loginFailed(GooglePlayServicesUtil.getErrorString(cr.getErrorCode()));
}
});
}
}
示例4: inviteFriends
import com.codename1.impl.android.IntentResultListener; //导入依赖的package包/类
@Override
public void inviteFriends(String appLinkUrl, String previewImageUrl, final Callback cb) {
if (AndroidNativeUtil.getActivity() == null) {
throw new RuntimeException("Cannot invite friends while running in the background.");
}
if (AppInviteDialog.canShow()) {
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
final CodenameOneActivity activity = (CodenameOneActivity) AndroidNativeUtil.getActivity();
if(cb == null){
AppInviteDialog.show(activity, content);
}else{
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
final CallbackManager mCallbackManager = CallbackManager.Factory.create();
activity.setIntentResultListener(new IntentResultListener() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
activity.restoreIntentResultListener();
}
});
appInviteDialog.registerCallback(mCallbackManager, new FacebookCallback<AppInviteDialog.Result>() {
@Override
public void onSuccess(AppInviteDialog.Result result) {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onSucess(null);
}
});
}
@Override
public void onCancel() {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onError(null, null, -1, "User Cancelled");
}
});
}
@Override
public void onError(final FacebookException e) {
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
cb.onError(null, e, 0, e.getMessage());
}
});
}
});
appInviteDialog.show(content);
}
}
}