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


Java IntentResultListener类代码示例

本文整理汇总了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);
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:22,代码来源:ZXingNativeCallsImpl.java

示例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);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:FacebookImpl.java

示例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()));
            }
        });
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:41,代码来源:GoogleImpl.java

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

}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:64,代码来源:FacebookImpl.java


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