-
Notifications
You must be signed in to change notification settings - Fork 1
English Doc
Hualin Song edited this page Sep 3, 2018
·
4 revisions
1,Add risesdk.jar dependencies. Copy risesdk.jar file under the libs directory in demo to your project for reference. (As shown in the following figure)

-dontwarn com.unity3d.**
-keep class com.android.client.** {
<methods>;
}
-keep class android.support.** {
*;
}
-keep class com.android.async.** {
public *;
}
-keep class com.android.common.** {
public *;
}
-keep class com.android.network.** {
public *;
}
-keep class com.android.view.** {
public *;
}3,Initialize Android SDK in Activity. Create AndroidSDK builder project, and provide initializing success callback.
@Override
protected void onCreate() {
AndroidSdk.Builder builder = new AndroidSdk.Builder();
builder.setSdkResultListener(new SdkResultListener() {
@Override
public void onInitialized() {
//sdk initialize success interface
Log.e("DEMO","sdk initialized");
}
@Override
public void onReceiveServerExtra(String data) {
// get callback data from server after initializing success
Log.e("DEMO","server data: " + data);
}
@Override
public void onReceiveNotificationData(String data) {
//get notification data after initializing success
Log.e("DEMO","noti: " + data);
}
});
AndroidSdk.onCreate(this, builder);
AndroidSdk.registerAdEventListener(new AdEventListener());
}
@Override
protected void onStart() {
super.onStart();
AndroidSdk.onStart();
}
@Override
protected void onStop() {
AndroidSdk.onStop();
super.onStop();
}
@Override
protected void onPause() {
super.onPause();
AndroidSdk.onPause();
}
@Override
protected void onPostResume() {
super.onPostResume();
AndroidSdk.onResume(this);
}
@Override
protected void onDestroy() {
AndroidSdk.onDestroy();
super.onDestroy();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
AndroidSdk.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}- Full screen ads (also called as Interstitial): needs to configure the specific position for ads display. We have pre-defined the following positions:
AndroidSdk.showFullAd(AndroidSdk.FULL_TAG_START); // game start
AndroidSdk.showFullAd(AndroidSdk.FULL_TAG_PAUSE); // game pause
AndroidSdk.showFullAd(AndroidSdk.FULL_TAG_PASS_LEVEL);//game pass level
AndroidSdk.showFullAd(AndroidSdk.FULL_TAG_EXIT); // game exit
AndroidSdk.showFullAd("xxx"); // you can customize the position to display full screen adsNotice: Do not show full screen ads in onResume() and onPause() during the life cycle of activity
- Banner
int[] bannerPos = {
AndroidSdk.POS_CENTER, /show banner at the center position
AndroidSdk.POS_CENTER_BOTTOM, // show banner at the middle bottom position
AndroidSdk.POS_CENTER_TOP, //show banner at the middle top position
AndroidSdk.POS_LEFT_BOTTOM, //show banner at the lower left position
AndroidSdk.POS_LEFT_TOP, //show banner at the upper left position
AndroidSdk.POS_RIGHT_BOTTOM, //show banner at the lower right position
AndroidSdk.POS_RIGHT_TOP // show banner at the upper right position
};
AndroidSdk.showBanner("default", bannerPos[0]); // show banner at the center position
AndroidSdk.closeBanner(); //close banner- Video ads
int rewardId = 1; //the reward id set from client side for video ads, its value is customizable, and based on this value to determine what and how many rewards items will be returned to players
if(AndroidSdk.hasRewardAd()){ // Check whether video ads exists or not
AndroidSdk.showRewardAd(rewardId);
}- Ads callback
builder.setRewardAdListener(new AdListener() {
@Override
public void onReceiveReward(boolean success, int rewardId) {
//success:whether video ads displayed successfully or not; rewardId:
: reward id set for video ads
Log.e("DeMO","on receive reward? " + id + ", success = " + success);
}
@Override
public void onFullAdClosed() {
//full screen ads closed
}
@Override
public void onFullAdClicked()
//full screen ads clicked
}
@Override
public void onVideoAdClosed() {
//video ads closed
}
@Override
public void onBannerAdClicked() {
// Banner clicked
}
@Override
public void onCrossAdClicked() {
// cross promotion ads clicked
}
});- Facebook Login
AndroidSdk.login();- Whether Facebook account logged in or not
boolean isLogin = AndroidSdk.isLogin()- Facebook Share
AndroidSdk.share(); - Facebook Like
AndroidSdk.like();- Facebook Invite: invite Facebook friends to install app or game
AndroidSdk.invite();- Facebook Challenge: Challenge your Facebook friends
AndroidSdk.challenge("haha title", "heihei message");- Get Facebook friend list
String friendsJson = AndroidSdk.friends();
//returned data in json format is as follows:
[
{
"id":"0000000000000001",//account id for Facebook Friend 1
"name":"Friend 1",// account name for Facebook Friend 1
"picture":"/data/empty_not_exists1"//absolute path where the profile picture of Facebook 1 is saved
},
{
"id":"0000000000000002",//account id for Facebook Friend 2
"name":"Friend 2",//account name for Facebook Friend 2
"picture":"/data/empty_not_exists2"//absolute path where the profile picture of Facebook 2 is saved
},
{
"id":"0000000000000003",//account id for Facebook Friend 3
"name":"Friend 3",//account name for Facebook Friend 3
"picture":"/data/empty_not_exists3"//absolute path where the profile picture of Facebook 3 is saved
}
]- Get my Facebook info
String meJson = AndroidSdk.me();
/ returned data in json format is as follows:
{
"id":"0000000000000000",//my Facebook account id
"name":"Me is me",// my Facebook account name
"picture":"/data/empty_not_exists"// absolute path where my Facebook profile picture is saved
}- Facebook Logout
AndroidSdk.logout();- Facebook interface callback:
builder.setUserCenterListener(new UserCenterListener() {
@Override
public void onReceiveLoginResult(boolean success) {
//callback for checking whether facebook logged in or not
Log.e("DEMO","login? " + success);
}
@Override
public void onReceiveInviteResult(boolean success) {
//callback for checking whether players successfully invite facebook friends to install app or game
Log.e("DEMO","invite? " + success);
}
@Override
public void onReceiveChallengeResult(int count) {
//callback for receiving challenge result, "count" stands for how many friends you challenged
Log.e("DEMO","challenge? " + " count: " + count);
}
@Override
public void onReceiveLikeResult(boolean success) {
//callback for receiving like result, to determine whether players liked successfully or not
Log.e("DEMO","like? " + success);
}
});int billId = 1; //billing id
AndroidSdk.pay(billId);//payment interface, pay for certain billing id
AndroidSdk.query(billId);//query payment result
/**
* AndroidSdk.pay(billId);//payment interface, pay for certain billing id
AndroidSdk.query(billId);//query payment result
PaymentResultListener is the callback class for the above two interfaces
*/
builder.setPaymentResultListener(new PaymentResultListener() {
@Override
public void onPaymentSuccess(int billId) {
//payment succeed
Log.d("DEMO","payment success: " + billId);
}
@Override
public void onPaymentFail(int billId) {
//payment failed
Log.d("DEMO","payment fail: " + billId);
}
@Override
public void onPaymentCanceled(int bill) {
/ payment cancelled
Log.d("DEMO","payment cancel: " + bill);
}
@Override
public void onPaymentSystemValid() {
//callback for checking whether environment is available for payment on phones/tablets
Log.d("DEMO", "pay system is valid");
}
});- Player's Level
int level = 1; //player's level
AndroidSdk.UM_setPlayerLevel(level);//collect data of player's level- Track times for entering certain page
String pageName = "Shop";
AndroidSdk.UM_onPageStart(pageName);//collect times for entering Shop page- Track times for exiting certain page
String pageName = "Shop";
AndroidSdk.UM_onPageEnd(pageName);//collect times for exiting Shop page- Track event name
String eventId = "EnterGame"; // event name
AndroidSdk.UM_onEvent(eventId);- Track event label
String eventId = "EnterGame"; // event name
String eventLabel = "eventLable";//certain event operation label
AndroidSdk.UM_onEvent(eventId, eventLabel);- Detailed grouping content for tracked events
HashMap<String, String> map = new HashMap<>(); //detailed grouping content for certain event
map.put("openGift", "roll");
int value = 1;// count statistics, like duration, amount of money
AndroidSdk.UM_onEventValue("EnterGame", map, value);- Track times for level start
String level = "Level" + 5;//level ,start from which level
AndroidSdk.UM_startLevel(level);- Track times for level failure
String level = "Level" + 5); //level ,which level is failed
AndroidSdk.UM_failLevel(level);- Track times for level completed
String level = "Level" + (new Random().nextInt(30) + 10); //level, which level is completed
AndroidSdk.UM_finishLevel(level);- In-app purchase analytics
double money = 5.0; //payment amount
String itemName = "Diamond"; // name of the purchased item
int number = 10;//amount of the purchased item
double price = 99.0;// price of the purchased item
AndroidSdk.UM_pay(money,itemName,number,price);- Booster
String itemName = "life potion"; //name of the booster to be purchased in game
int number = 10;// amount of purchased boosters
double price = 99.0;// price of purchased booster
AndroidSdk.UM_buy(itemName,count,price); - Booster usage
String itemName = "life potion"; // name of the used booster
int count = 10;// amount of the used booster
double price = 99.0;// price of the used booster
AndroidSdk.UM_use(itemName,count,price); - Extra bonus
String itemName = "life potion"; //name of the rewarded booster
int number = 5;// amount of the rewarded booster
double price = 99.0;//price of the reward booster
int trigger = 1;//Events that trigger reward, its value ranges from 1 to 10. “1” is defined as “system reward”. About 2-10,you have to define corresponding rewards respectively
AndroidSdk.UM_bonus(itemName,number,price,trigger); - Check whether network is connected or not
boolean isNetworkConnected = AndroidSdk.isNetworkConnected();- Pop up android native toast notification
String messageContent="toast content";
AndroidSdk.toast(messageContent);- Pop up android native alert dialog
String title = "title";
String message = "content";
AndroidSdk.alert(title,message);- Game/App exit
AndroidSdk.onQuit();- Cache file
String url = "http://xxxx.png";//file download link
String path = AndroidSdk.cacheUrl(url); //return absolute path for saving files(/sdcard/0/.cache/383292918283483291)- 5-star rating module
AndroidSdk.rateUs();- Add Google Analytics for apps and games
AndroidSdk.track("shop"); //Track behavior on shop page
AndroidSdk.track("shop","buy"); //Track equipment purchase data on shop page
AndroidSdk.track("shop","buy","life potion"); //Track life potion purchase data on shop page9,Detailed explanation about the sdk integration is available in demo. If you have any question, please feel free to contact us via appdev@ivymobile.com. We will reply you as soon as possible. Thank you!