本文整理汇总了Java中com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient类的典型用法代码示例。如果您正苦于以下问题:Java BMSClient类的具体用法?Java BMSClient怎么用?Java BMSClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BMSClient类属于com.ibm.mobilefirstplatform.clientsdk.android.core.api包,在下文中一共展示了BMSClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bmsClient = BMSClient.getInstance();
try {
//initialize SDK with IBM Bluemix application ID and route
//You can find your backendRoute and backendGUID in the Mobile Options section on top of your Bluemix application dashboard
//TODO: Please replace <APPLICATION_ROUTE> with a valid ApplicationRoute and <APPLICATION_ID> with a valid ApplicationId
bmsClient.initialize(this, "<APPLICATION_ROUTE>", "<APPLICATION_ID>", BMSClient.REGION_US_SOUTH);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
// Init UI
initListView();
initSwipeRefresh();
// Must create and set default MCA Auth Manager in order for the delete endpoint to work. This is new in core version 2.0.
MCAAuthorizationManager MCAAuthMan = MCAAuthorizationManager.createInstance(this);
bmsClient.setAuthorizationManager(MCAAuthMan);
}
示例2: performInitializations
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
private void performInitializations() {
try {
BMSClient.getInstance().initialize(getApplicationContext(), backendURL, backendGUID, BMSClient.REGION_US_SOUTH);
} catch (MalformedURLException e) {
e.printStackTrace();
}
MCAAuthorizationManager mcaAuthorizationManager = MCAAuthorizationManager.createInstance(this.getApplicationContext());
mcaAuthorizationManager.registerAuthenticationListener(customRealm, new MyChallengeHandler());
// to make the authorization happen next time
mcaAuthorizationManager.clearAuthorizationData();
BMSClient.getInstance().setAuthorizationManager(mcaAuthorizationManager);
Logger.setLogLevel(Logger.LEVEL.DEBUG);
Logger.setSDKDebugLoggingEnabled(true);
}
示例3: clearAuthorizationData
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Clear the local stored authorization data
*/
public void clearAuthorizationData() {
preferences.accessToken.clear();
preferences.idToken.clear();
preferences.userIdentity.clear();
if (BMSClient.getInstance() != null && BMSClient.getInstance().getCookieManager() != null) {
CookieStore cookieStore = BMSClient.getInstance().getCookieManager().getCookieStore();
if(cookieStore != null) {
for (URI uri : cookieStore.getURIs()) {
for (HttpCookie cookie : cookieStore.get(uri)) {
if (cookie.getName().equals(TAI_COOKIE_NAME)) {
cookieStore.remove(uri, cookie);
}
}
}
}
}
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:21,代码来源:MCAAuthorizationManager.java
示例4: startHandleChallenges
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Handles authentication challenges.
*
* @param jsonChallenges Collection of challenges.
* @param response Server response.
*/
private void startHandleChallenges(JSONObject jsonChallenges, Response response) {
ArrayList<String> challenges = getRealmsFromJson(jsonChallenges);
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
if (isAuthorizationRequired(response)) {
setExpectedAnswers(challenges);
}
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonChallenges.optJSONObject(realm);
handler.handleChallenge(this, challenge, context);
} else {
throw new RuntimeException("Challenge handler for realm is not found: " + realm);
}
}
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:26,代码来源:AuthorizationRequestManager.java
示例5: processFailures
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Processes authentication failures.
*
* @param jsonFailures Collection of authentication failures.
*/
private void processFailures(JSONObject jsonFailures) {
if (jsonFailures == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonFailures);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonFailures.optJSONObject(realm);
handler.handleFailure(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:23,代码来源:AuthorizationRequestManager.java
示例6: processSuccesses
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Processes authentication successes.
*
* @param jsonSuccesses Collection of authentication successes.
*/
private void processSuccesses(JSONObject jsonSuccesses) {
if (jsonSuccesses == null) {
return;
}
MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();
ArrayList<String> challenges = getRealmsFromJson(jsonSuccesses);
for (String realm : challenges) {
ChallengeHandler handler = authManager.getChallengeHandler(realm);
if (handler != null) {
JSONObject challenge = jsonSuccesses.optJSONObject(realm);
handler.handleSuccess(context, challenge);
} else {
logger.error("Challenge handler for realm is not found: " + realm);
}
}
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:23,代码来源:AuthorizationRequestManager.java
示例7: onCreate
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView buttonText = (TextView) findViewById(R.id.button_text);
// initialize SDK with IBM Bluemix application ID and REGION, TODO: Update region if not using Bluemix US SOUTH
BMSClient.getInstance().initialize(this, BMSClient.REGION_US_SOUTH);
// Runtime Permission handling required for SDK 23+
if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
buttonText.setClickable(false);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.GET_ACCOUNTS}, PERMISSION_REQUEST_GET_ACCOUNTS);
}
// Register this activity as the default auth listener
Log.i(TAG, "Registering Google Auth Listener");
// Must create MCA auth manager before registering Google auth Manager
//TODO: Please replace <APP_GUID> with a valid Application GUID from your MCA instance
MCAAuthorizationManager MCAAuthMan = MCAAuthorizationManager.createInstance(this, "<APP_GUID>");
BMSClient.getInstance().setAuthorizationManager(MCAAuthMan);
GoogleAuthenticationManager.getInstance().register(this);
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-samples-android-helloauthentication,代码行数:26,代码来源:MainActivity.java
示例8: pingBluemix
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Called when ping bluemix button is pressed.
* Attempts to access protected Bluemix backend, kicking off the Authentication login prompt.
* @param view the button pressed.
*/
public void pingBluemix(View view) {
TextView buttonText = (TextView) findViewById(R.id.button_text);
buttonText.setClickable(false);
TextView responseText = (TextView) findViewById(R.id.response_text);
responseText.setText(R.string.Connecting);
Log.i(TAG, "Attempting to Connect");
// Testing the connection to Bluemix by attempting to obtain an authorization header, using this Activity to handle the response.
BMSClient.getInstance().getAuthorizationManager().obtainAuthorization(this, this);
// As an alternative, you can send a Get request using the Bluemix Mobile Services Core sdk to send the request to a protected resource on the Node.js application to kick off Authentication. See example below:
// new Request(<YOUR_BLUEMIX_APP_ROUTE> + "/protected", Request.GET).send(this, this); TODO: Replace <YOUR_BLUEMIX_APP_ROUTE> with your appRoute on Bluemix
// The Node.js code was provided in the MobileFirst Services Starter boilerplate.
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-samples-android-helloauthentication,代码行数:22,代码来源:MainActivity.java
示例9: initialize
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* MFPPush Intitialization method with clientSecret and Push App GUID.
* <p/>
*
* @param context this is the Context of the application from getApplicationContext()
* @param appGUID The unique ID of the Push service instance that the application must connect to.
* @param pushClientSecret ClientSecret from the push service.
* @param options - The MFPPushNotificationOptions with the default parameters
*
*/
public void initialize(Context context, String appGUID, String pushClientSecret,MFPPushNotificationOptions options) {
try {
if (MFPPushUtils.validateString(pushClientSecret) && MFPPushUtils.validateString(appGUID)) {
// Get the applicationId and backend route from core
clientSecret = pushClientSecret;
applicationId = appGUID;
appContext = context.getApplicationContext();
isInitialized = true;
validateAndroidContext();
//Storing the messages url and the client secret.
//This is because when the app is not running and notification is dismissed/cleared,
//there wont be applicationId and clientSecret details available to
//MFPPushNotificationDismissHandler.
SharedPreferences sharedPreferences = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_MESSAGES_URL, buildMessagesURL());
MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, MFPPush.PREFS_MESSAGES_URL_CLIENT_SECRET, clientSecret);
MFPPushUtils.storeContentInSharedPreferences(sharedPreferences, PREFS_BMS_REGION, BMSClient.getInstance().getBluemixRegionSuffix());
if (options != null){
setNotificationOptions(context,options);
this.regId = options.getDeviceid();
}
} else {
logger.error("MFPPush:initialize() - An error occured while initializing MFPPush service. Add a valid ClientSecret and push service instance ID Value");
throw new MFPPushException("MFPPush:initialize() - An error occured while initializing MFPPush service. Add a valid ClientSecret and push service instance ID Value", INITIALISATION_ERROR);
}
} catch (Exception e) {
logger.error("MFPPush:initialize() - An error occured while initializing MFPPush service.");
throw new RuntimeException(e);
}
}
示例10: computeRegId
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
private void computeRegId() {
logger.debug("MFPPush:computeRegId() Computing device's registrationId");
if (regId == null) {
AuthorizationManager authorizationManager = BMSClient.getInstance().getAuthorizationManager();
regId = authorizationManager.getDeviceIdentity().getId();
logger.debug("MFPPush:computeRegId() - DeviceId obtained from AuthorizationManager is : " + regId);
}
}
示例11: onMessageReceived
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
@Override
public void onMessageReceived(RemoteMessage message) {
String from = message.getFrom();
Map<String, String> data = message.getData();
JSONObject dataPayload = new JSONObject(data);
logger.info("MFPPushIntentService:onMessageReceived() - New notification received. Payload is: "+ dataPayload.toString());
String messageId = getMessageId(dataPayload);
String action = data.get(ACTION);
if (action != null && action.equals(DISMISS_NOTIFICATION)) {
logger.debug("MFPPushIntentService:handleMessageIntent() - Dismissal message from GCM Server");
dismissNotification(data.get(NID).toString());
} else {
Context context = getApplicationContext();
String regionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
if(regionSuffix == null) {
String region = MFPPushUtils.getContentFromSharedPreferences(context, PREFS_BMS_REGION);
BMSClient.getInstance().initialize(context, region);
}
MFPPush.getInstance().changeStatus(messageId, MFPPushNotificationStatus.RECEIVED);
if(isAppForeground()) {
Intent intent = new Intent(MFPPushUtils.getIntentPrefix(context)
+ GCM_MESSAGE);
intent.putExtra(GCM_EXTRA_MESSAGE, new MFPInternalPushMessage(dataPayload));
getApplicationContext().sendBroadcast(intent);
} else {
MFPPush.getInstance().sendMessageDeliveryStatus(context, messageId, MFPPushConstants.SEEN);
onUnhandled(context, dataPayload);
}
}
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-push,代码行数:35,代码来源:MFPPushIntentService.java
示例12: MFPPushUrlBuilder
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
public MFPPushUrlBuilder(String applicationId) {
if (MFPPush.overrideServerHost != null){
pwUrl_.append(MFPPush.overrideServerHost);
reWriteDomain = "";
} else {
pwUrl_.append(BMSClient.getInstance().getDefaultProtocol());
pwUrl_.append("://");
pwUrl_.append(IMFPUSH);
String regionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
if (regionSuffix != null && regionSuffix.contains(STAGE_TEST) || regionSuffix.contains(STAGE_DEV)){
pwUrl_.append(STAGE_PROD_URL);
if (regionSuffix.contains(STAGE_TEST)) {
reWriteDomain = STAGE_TEST_URL;
}
else {
reWriteDomain = STAGE_DEV_URL;
}
}else {
pwUrl_.append(BMSClient.getInstance().getBluemixRegionSuffix());
reWriteDomain = "";
}
}
pwUrl_.append(FORWARDSLASH);
pwUrl_.append(IMFPUSH);
pwUrl_.append(FORWARDSLASH);
pwUrl_.append(V1);
pwUrl_.append(FORWARDSLASH);
pwUrl_.append(APPS);
pwUrl_.append(FORWARDSLASH);
pwUrl_.append(applicationId);
pwUrl_.append(FORWARDSLASH);
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-push,代码行数:36,代码来源:MFPPushUrlBuilder.java
示例13: createInstance
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
/**
* Init singleton instance with context
* @param context Application context
* @return The singleton instance
*/
public static synchronized MCAAuthorizationManager createInstance(Context context) {
if (instance == null) {
instance = new MCAAuthorizationManager(context.getApplicationContext());
instance.bluemixRegionSuffix = BMSClient.getInstance().getBluemixRegionSuffix();
instance.tenantId = BMSClient.getInstance().getBluemixAppGUID();
AuthorizationRequest.setup();
}
return instance;
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:17,代码来源:MCAAuthorizationManager.java
示例14: onCreate
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initialize SDK with IBM Bluemix application region, add Bluemix application route for connectivity testing
// You can find your backendRoute and backendGUID in the Mobile Options section on top of your Bluemix MCA dashboard
// TODO: Please replace <APPLICATION_ROUTE> with a valid ApplicationRoute and change region appropriately
BMSClient.getInstance().initialize(this, BMSClient.REGION_US_SOUTH);
appRoute = "<APPLICATION_ROUTE>";
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-samples-android-helloworld,代码行数:12,代码来源:MainActivity.java
示例15: onCreate
import com.ibm.mobilefirstplatform.clientsdk.android.core.api.BMSClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initialize core SDK with IBM Bluemix application Region, TODO: Update region if not using Bluemix US SOUTH
BMSClient.getInstance().initialize(this, BMSClient.REGION_US_SOUTH);
// Grabs push client sdk instance
push = MFPPush.getInstance();
// Initialize Push client
// You can find your App Guid and Client Secret by navigating to the Configure section of your Push dashboard, click Mobile Options (Upper Right Hand Corner)
// TODO: Please replace <APP_GUID> and <CLIENT_SECRET> with a valid App GUID and Client Secret from the Push dashboard Mobile Options
push.initialize(this, "<APP_GUID>", "<CLIENT_SECRET>");
// Create notification listener and enable pop up notification when a message is received
notificationListener = new MFPPushNotificationListener() {
@Override
public void onReceive(final MFPSimplePushNotification message) {
Log.i(TAG, "Received a Push Notification: " + message.toString());
runOnUiThread(new Runnable() {
public void run() {
new android.app.AlertDialog.Builder(MainActivity.this)
.setTitle("Received a Push Notification")
.setMessage(message.getAlert())
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
})
.show();
}
});
}
};
}