This lesson descript how to call nuwa app feature by delegating the work to another nuwa app on the device.
It allow developer do not need implement detail specific flow, and quick integrate on 3rd app.
NUWA APP Feature InterfaceNUWA APP Feature ListFace TrainingExampleMeasure TemperatureParametersGet Activity ResultExampleLaunch Video CallExamplePlay mbtx format ContentPrepare conditionExample of play mbtxExample of stop playReceive Play statusNotification presentHeadsUp Notification Message compositionIntent ParametersSample CodeExample effectNotification BarExample effect
Allow developer call nuwa face recognition app to add one Contact user.
xprivate final int ACTIVITY_FACE_RECOGNITION = 1;
private void lunchFaceRecogActivity() {
Intent intent = new Intent("com.nuwarobotics.action.FACE_REC");
intent.setPackage("com.nuwarobotics.app.facerecognition2");
intent.putExtra("EXTRA_3RD_REC_ONCE", true);//enroll once or not
intent.putExtra("EXTRA_3RD_CONFIG_NAME", string );//provide name and skip input name step.
startActivityForResult(intent, ACTIVITY_FACE_RECOGNITION);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult, requestCode=" + requestCode + ", resultCode=" + resultCode);
if (resultCode > 0) {
switch (requestCode) {
case ACTIVITY_FACE_RECOGNITION:
Long mFaceID = data.getLongExtra("EXTRA_RESULT_FACEID", 0);
String mName = data.getStringExtra("EXTRA_RESULT_NAME");
Log.d(TAG, "onActivityResult, faceid=" + mFaceID + ", name=" + mName);
//developer code
break;
}
} else {
Log.d(TAG, "unexception exit");
}
}
=================================================
Allow developer call nuwa health app to get human temperature
NOTICE : It must download Nuwa Health App from NuwaStore and work with NUWA Ocular
product
Robot Support Version :
Intent | ||
---|---|---|
Action | com.nuwarobotics.health.action.facerec | |
Extra | HealthConstant.EXTRA_REPORT | 1: return name and temperature |
Extra | HealthConstant.EXTRA_PRECISE | 0: Flir 1: Melexis |
Extra | HealthConstant.EXTRA_KEBBI_FACE | 0: Don’t show Kebbi face 1: Show Kebbi face |
Extra | HealthConstant.EXTRA_FACE_RECOG | false: Don’t recognize face true: Recognize face |
Request Code | HealthConstant.MEASURE_FLOW_CONTINUOUS_SINGLE | 1: Measure single person. |
Filed | Intent Extra | DataType |
---|---|---|
Face Name | getStringExtra(HealthConstant.INTENT_DATA_FACE) | String |
Temperature | getStringExtra(HealthConstant.INTENT_DATA_TEMPERATURE) | String |
Time | getStringExtra(HealthConstant.INTENT_DATA_TIME) | DateTime |
Mask | getStringExtra(HealthConstant.INTENT_DATA_MASK) | Y: Wear mask N: No mask |
xxxxxxxxxx
private void lunchTemperatureActivity() {
Intent intent = new Intent("com.nuwarobotics.health.action.facerec");
intent.putExtra(HealthConstant.EXTRA_REPORT,1);
intent.putExtra(HealthConstant.EXTRA_PRECISE,0);
intent.putExtra(HealthConstant.EXTRA_FACE_RECOG,false);
startActivityForResult(intent, HealthConstant.MEASURE_FLOW_CONTINUOUS_SINGLE);
}•
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult, requestCode=" + requestCode + ", resultCode=" + resultCode);
if (resultCode > 0) {
switch(resultCode) {•
case HealthConstant.FACE_RESULT_SUCCESS:•
String face_name = data.getStringExtra(HealthConstant.INTENT_DATA_FACE);•
String temperature = data.getStringExtra(HealthConstant.INTENT_DATA_TEMPERATURE);•
String time = data.getStringExtra(HealthConstant.INTENT_DATA_TIME);•
String mask = data.getStringExtra(HealthConstant.INTENT_DATA_MASK);•
break;•
}
} else {
Log.d(TAG, "unexception exit");
}
}
=================================================
Allow developer lunch NUWA Video Call App and call to target contact
xxxxxxxxxx
String contact_name = "xxx";//specific name of family contact
Bundle mIntentBundle = new Bundle();
mIntentBundle.putString("callee", contact_name);
Intent intent = new Intent();
intent.putExtras(mIntentBundle);
intent.setClassName("com.nuwarobotics.app.videocall", "com.nuwarobotics.app.videocall.SignalingService");
mContext.startService(intent);
=================================================
Allow user play mbtx file which exported from Nuwa BizTool Content Editor
Download *.mbtx file from Nuwa ContentEditor
manually clone *.mbtx file to /storage/emulated/0/contenteditor/
Execute following code and set PlayId as abc
xxxxxxxxxx
public static final int REQUEST_CODE = 201 ;
Intent intent = new Intent();
ComponentName comp = new ComponentName("com.nuwarobotics.app.nuwaplayer","com.nuwarobotics.app.nuwaplayer.PlayContentEditorActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction("com.nuwarobotics.app.nuwaplayer.action.PLAY_MBTX");
intent.setComponent(comp);
intent.putExtra("PlayId", "abc");//the file name put in /sdcard/contenteditor/
context.startActivityForResult(intent, REQUEST_CODE);
xxxxxxxxxx
//Please make sure you start activity by startActivityForResult
finishActivity(REQUEST_CODE);
xxxxxxxxxx
public static final String PLAYER_PLAYING = "com.nuwaplayer.player.PLAYING";
public static final String PLAYER_STOP = "com.nuwaplayer.player.STOP";
public static final String PLAYER_PAUSE = "com.nuwaplayer.player.PAUSE";
public class PlayerStatusReceiver extends BroadcastReceiver {
public static final String TAG = "PlayerStatusReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if (Constant.PLAYER_PLAYING.equals(intent.getAction())) {
//playing status, do something
} else if (Constant.PLAYER_STOP.equals(intent.getAction())) {
//motion play finished, do something
} else if (Constant.PLAYER_PAUSE.equals(intent.getAction())) {
//motion player was paused, do something
}
}
}
private void registerPlayerReceiver() {
receiver = new PlayerStatusReceiver();
IntentFilter filter = new IntentFilter(Constant.PLAYER_PAUSE);
filter.addAction(Constant.PLAYER_PLAYING);
filter.addAction(Constant.PLAYER_STOP);
registerReceiver(receiver, filter);
}
extra_bundle:Collection of all parameters of notification extra_app_icon:App icon(support 80dp X 80dp) extra_app_name:Application name of an App extra_content:Message content, which is supported ths String or SpannString class of CharSequence extra_intent:Go to the intent after touching a headup notification(PendingIntent)
xxxxxxxxxx
private final String EXTRA_BUNDLE = "extra_bundle";
private final String EXTRA_APP_ICON = "extra_app_icon";
private final String EXTRA_APP_NAME = "extra_app_name";
private final String EXTRA_CONTENT = "extra_content";
private final String EXTRA_INTENT = "extra_intent";
private final ACTION_NUWA_SHOW_HEADUP_NOTIFICATION = "nuwarobotics.intent.action.SHOW_NOTIFICATION";
private final PKG_NUWA_KIWI_SERVICE = "com.nuwarobotics.service";
public void showLongMsg(View v){
Intent intent = new Intent();
intent.setAction(ACTION_NUWA_SHOW_HEADUP_NOTIFICATION);
intent.setPackage(PKG_NUWA_KIWI_SERVICE);
Icon icon = Icon.createWithResource(this, R.drawable.ic_longmsg); //API 23
//PendingIntent for trigger the next step after touch a notification
ComponentName cpName = new ComponentName("com.nuwarobotics.app.robottheater",
"com.nuwarobotics.app.robottheater.TheaterActivity");
Intent clickNotificationIntent = new Intent();
clickNotificationIntent.setComponent(cpName);
PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
clickNotificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Bundle bundle = new Bundle();
bundle.putParcelable(EXTRA_APP_ICON, icon);
bundle.putCharSequence(EXTRA_APP_NAME, "大腦戰爭");
bundle.putCharSequence(EXTRA_CONTENT, "大腦戰爭新的遊戲已經來了喔!快點觸碰這個訊息,加入新遊戲的行列!" +
"目前缺少你一個人的參加喔~~還有早鳥方案有提供新的道具,讓剛加入遊戲的你能快速上手,如虎添翼喔!說了這麼多" +
"你還不心動嗎? 馬上行動吧! 啾咪喔!");
bundle.putParcelable(EXTRA_INTENT, pendingIntent);
intent.putExtra(EXTRA_BUNDLE, bundle);
this.sendBroadcast(intent);
}
Use android native way. (https://developer.android.com/training/notify-user/build-notification)