當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。