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


Java AuthenticationResponse类代码示例

本文整理汇总了Java中com.spotify.sdk.android.authentication.AuthenticationResponse的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationResponse类的具体用法?Java AuthenticationResponse怎么用?Java AuthenticationResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onAuthenticationComplete

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void onAuthenticationComplete(AuthenticationResponse authResponse, String clientID) {
  Log.d("DEBUG", "Got authentication token");
  if (mPlayer == null) {
    Config playerConfig = new Config(this, authResponse.getAccessToken(), clientID);
    mPlayer = Spotify.getPlayer(playerConfig, this, new SpotifyPlayer.InitializationObserver() {
      @Override
      public void onInitialized(SpotifyPlayer player) {
        Log.d("DEBUG", "-- Player initialized --");
        mPlayer
            .setConnectivityStatus(mOperationCallback, getNetworkConnectivity(MainActivity.this));
        mPlayer.addNotificationCallback(MainActivity.this);
        mPlayer.addConnectionStateCallback(MainActivity.this);
      }

      @Override
      public void onError(Throwable error) {
        Log.d("DEBUG", "Error in initialization: " + error.getMessage());
      }
    });
  } else {
    mPlayer.login(authResponse.getAccessToken());
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:24,代码来源:MainActivity.java

示例2: processRequestToken

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
String processRequestToken(int requestCode, int resultCode, Intent data) {
  if (requestCode == REQUEST_CODE) {
    final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);

    SpotifyConfigFragment.setAccessToken(response.getAccessToken());

    switch (response.getType()) {
      case TOKEN:
        Log.d("DEBUG", "Spotify Token: " + response.getAccessToken());

        onAuthenticationComplete(response, getString(R.string.spotify_client_id));
        SpotifyConfigFragment.setIsLoggedIn(true);
        break;
      case ERROR:
        Log.d("DEBUG", "Spotify Error: " + response.getError());
        break;
      default:
        Log.d("DEBUG", "Spotify Other: " + response.getState());
        break;
    }
  }

  return SpotifyConfigFragment.getAccessToken();
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:25,代码来源:MainActivity.java

示例3: initializePlayer

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void initializePlayer() {
    SharedPreferences prefsAppData = getSharedPreferences(getString(R.string.sharedpreferences_global), Context.MODE_PRIVATE);
    if (prefsAppData.getInt(getString(R.string.responseType), -1) == AuthenticationResponse.Type.TOKEN.ordinal()) {

        Config config = new Config(
                this,
                prefsAppData.getString(getString(R.string.spotifyAccessToken_value), null),
                prefsAppData.getString(getString(R.string.clientId), null)
        );
        spotifyPlayer = Spotify.getPlayer(config, this, new Player.InitializationObserver() {
            @Override
            public void onInitialized(Player player) {
                player.addConnectionStateCallback(MainActivity.connectionStateCallback);
                player.addPlayerNotificationCallback(TracksActivity.this);
            }

            @Override
            public void onError(Throwable throwable) {
                Log.e("PLAYER", "ERROR: " + throwable.getMessage());
            }
        });

    }
}
 
开发者ID:sharaquss,项目名称:Betterfy,代码行数:25,代码来源:TracksActivity.java

示例4: onCreate

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_authentication);
    ((Injector) getApplication()).inject(this);
    overridePendingTransition(R.anim.short_fade_in, R.anim.short_fade_out);

    AuthenticationRequest authRequest = new AuthenticationRequest.Builder(
        BuildConfig.SPOTIFY_CLIENT_ID,
        AuthenticationResponse.Type.TOKEN,
        SpotifyConstants.REDIRECT_URI)
        .setScopes(SpotifyConstants.DEFAULT_USER_SCOPES)
        .build();

    AuthenticationClient.openLoginActivity(this,
        ApplicationConstants.LOGIN_INTENT_REQUEST_CODE,
        authRequest);
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:19,代码来源:SpotifyAuthenticationActivity.java

示例5: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    // Check if result comes from the correct activity
    if (requestCode == REQUEST_CODE) {
        AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
        if (response.getType() == AuthenticationResponse.Type.TOKEN) {
            // TODO progress dialog
            SpotifyTvApplication.getInstance().startSpotifySession(MainActivity.this, response.getAccessToken(), new Runnable() {
                @Override
                public void run() {
                    init();
                }
            }, new Runnable() {
                @Override
                public void run() {
                    showError();
                }
            });
        } else {
            showError();
        }
    }
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:26,代码来源:MainActivity.java

示例6: onNewIntent

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Uri uri = intent.getData();
    if (uri != null) {
        AuthenticationResponse response = SpotifyAuthentication.parseOauthResponse(uri);
        Spotify spotify = new Spotify(response.getAccessToken());
        mPlayer = spotify.getPlayer(this, "BeatMap", this, new Player.InitializationObserver()
        {
            @Override
            public void onInitialized() {
                mPlayer.addConnectionStateCallback(LoginActivity.this);
                mPlayer.addPlayerNotificationCallback(LoginActivity.this);


            }

            @Override
            public void onError(Throwable throwable) {
                Log.e("LoginActivity", "Could not initialize player: " + throwable.getMessage());
            }
        });
    }
}
 
开发者ID:ohEmily,项目名称:BeatMap,代码行数:25,代码来源:LoginActivity.java

示例7: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // If logged into Spotify, retrieve an access code to make requests
    if (requestCode == LOGIN_REQUEST_CODE) {
        AuthenticationResponse response = AuthenticationClient
                .getResponse(LOGIN_REQUEST_CODE, data);
        switch (response.getType()){
            // If received token
            case TOKEN:
                SpotifyManager.ACCESS_TOKEN = response.getAccessToken();
                Log.wtf(TAG, "Got access token");
                mSongDataFragment.notifySongDataAdapter();
                break;
            case ERROR:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "ERROR retrieving access token");
                break;
            case EMPTY:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "EMPTY access token");
                break;
            default:
                SpotifyManager.ACCESS_TOKEN = SpotifyManager.NULL_ACCESS_TOKEN;
                Log.wtf(TAG, "Could not retrieve access token");
                break;
        }
    }
}
 
开发者ID:AkshayPall,项目名称:Songify,代码行数:30,代码来源:MainActivity.java

示例8: authenticateSpotify

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/**
     * Used to get access token to make any calls to the Spotify Api
     * @param callingActivity
     */
    public static void authenticateSpotify (Activity callingActivity){
        AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(
                callingActivity.getResources().getString(R.string.spotify_client_id),
                AuthenticationResponse.Type.TOKEN,
                callingActivity.getResources().getString(R.string.spotify_redirect_uri)
        );
//        builder.setScopes(new String[]{"streaming"});
        AuthenticationRequest request = builder.build();
        AuthenticationClient.openLoginActivity(
                callingActivity,
                LOGIN_REQUEST_CODE,
                request
        );
    }
 
开发者ID:AkshayPall,项目名称:Songify,代码行数:19,代码来源:SpotifyManager.java

示例9: onCreate

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    AuthenticationRequest.Builder builder =
            new AuthenticationRequest.Builder(
                    CLIENT_ID,
                    AuthenticationResponse.Type.TOKEN,
                    REDIRECT_URI);

    builder.setScopes(SpotifyAuthorizationScopes.FULL_ACCESS_SCOPES);
    AuthenticationRequest request = builder.build();

    Log.e("STARTUP", "SPOTIFY TOKEN: " + Utils.getStringFromSharedPreferences(this, R.string.sharedpreferences_global, getString(R.string.spotifyAccessToken_value)));
    Log.e("STARTUP", "SPOTIFY EXPIRY: " + Utils.getSharedPreferences(this, R.string.sharedpreferences_global).getInt(getString(R.string.spotifyAccessToken_expiration), -1));

    Snackbar.make(
            getWindow().getDecorView().getRootView(),
            Utils.checkInternetConnectionString(this),
            Snackbar.LENGTH_LONG
    ).show();

    connectionStateCallback = this;
    AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);

    buildRecycler();
}
 
开发者ID:sharaquss,项目名称:Betterfy,代码行数:30,代码来源:MainActivity.java

示例10: getAuthenticationRequest

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private AuthenticationRequest getAuthenticationRequest(AuthenticationResponse.Type type) {
    return new AuthenticationRequest.Builder(CLIENT_ID, type, getRedirectUri().toString())
            .setShowDialog(false)
            .setScopes(new String[]{"user-read-email"})
            .setCampaign("your-campaign-token")
            .build();
}
 
开发者ID:spotify,项目名称:android-auth,代码行数:8,代码来源:MainActivity.java

示例11: onActivityResult

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data);

    if (AUTH_TOKEN_REQUEST_CODE == requestCode) {
        mAccessToken = response.getAccessToken();
        updateTokenView();
    } else if (AUTH_CODE_REQUEST_CODE == requestCode) {
        mAccessCode = response.getCode();
        updateCodeView();
    }
}
 
开发者ID:spotify,项目名称:android-auth,代码行数:14,代码来源:MainActivity.java

示例12: buildRequest

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
 * Build the REquest according to the configuration given
 *
 * @return
 */
private static AuthenticationRequest buildRequest(final Type type, final String apiCallback, final String[] scopes) {
    AuthenticationResponse.Type spotifyType = (type == Type.CODE) ? AuthenticationResponse.Type.CODE : AuthenticationResponse.Type.TOKEN;

    AuthenticationRequest.Builder builder = new AuthenticationRequest
            .Builder(SpotifyManager.API_KEY, spotifyType, apiCallback).setScopes(scopes);
    return builder.build();
}
 
开发者ID:joxad,项目名称:android-easy-spotify,代码行数:13,代码来源:SpotifyManager.java

示例13: onNewIntent

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
 * Called when used the method {@link #loginWithBrowser(Activity, Type, int, String[], OAuthListener)}
 *
 * @param intent
 */
public static void onNewIntent(Intent intent) {
    Uri uri = intent.getData();
    if (uri != null) {
        AuthenticationResponse response = AuthenticationResponse.fromUri(uri);
        handleResponse(response);
    }
}
 
开发者ID:joxad,项目名称:android-easy-spotify,代码行数:13,代码来源:SpotifyManager.java

示例14: handleResponse

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
/***
 * Manage the response of Spotify
 *
 * @param response
 */
private static void handleResponse(AuthenticationResponse response) {
    switch (response.getType()) {
        // Response was successful and contains auth token
        case TOKEN:
            SpotifyManager.oAuthListener.onReceived(response.getAccessToken());
            break;
        case CODE:
            SpotifyManager.oAuthListener.onReceived(response.getCode());
            break;
        case ERROR:
            SpotifyManager.oAuthListener.onError(response.getError());
            break;
    }
}
 
开发者ID:joxad,项目名称:android-easy-spotify,代码行数:20,代码来源:SpotifyManager.java

示例15: login

import com.spotify.sdk.android.authentication.AuthenticationResponse; //导入依赖的package包/类
private void login(JSONArray scopes, Boolean fetchTokenManually) {
    AuthenticationResponse.Type authType = fetchTokenManually ? AuthenticationResponse.Type.CODE :AuthenticationResponse.Type.TOKEN;


    AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(clientId,
            authType,
            redirectUri);
    builder.setScopes(new String[]{"user-read-private", "streaming"});
    builder.setShowDialog(true);
    AuthenticationRequest request = builder.build();

    Log.d(TAG, "Client ID " + clientId + "AUTH RESPONSE TYPE " + AuthenticationResponse.Type.TOKEN + "REDIRECT URI " + redirectUri + " Scopes " + scopes + " manual " + fetchTokenManually);

    AuthenticationClient.openLoginActivity(cordova.getActivity(), REQUEST_CODE, request);
}
 
开发者ID:pmwisdom,项目名称:cordova-spotify-plugin,代码行数:16,代码来源:CDVSpotify.java


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