本文整理汇总了Java中com.unity3d.player.UnityPlayerActivity类的典型用法代码示例。如果您正苦于以下问题:Java UnityPlayerActivity类的具体用法?Java UnityPlayerActivity怎么用?Java UnityPlayerActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnityPlayerActivity类属于com.unity3d.player包,在下文中一共展示了UnityPlayerActivity类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import com.unity3d.player.UnityPlayerActivity; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
int id = intent.getIntExtra("id", 0);
String gameObject = intent.getStringExtra("gameObject");
String handlerMethod = intent.getStringExtra("handlerMethod");
String actionId = intent.getStringExtra("actionId");
boolean foreground = intent.getBooleanExtra("foreground", true);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(id);
if (foreground) {
Intent launchIntent = new Intent(context, UnityPlayerActivity.class);
launchIntent.setPackage(null);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(launchIntent);
}
UnityPlayer.UnitySendMessage(gameObject, handlerMethod, actionId);
}
示例2: setLocalNotification
import com.unity3d.player.UnityPlayerActivity; //导入依赖的package包/类
/**
* ローカル通知をセットする
* @param notificationId 通知ID
* @param title 通知タイトル
* @param message 通知メッセージ
* @param sentAt 何秒後に通知するか
* @param isUnique 通知を重複させないか
*/
public static void setLocalNotification(int notificationId, String title, String message, int sentAt, boolean isUnique) {
// Delete duplicate notification
if (isUnique)
cancelLocalNotification(notificationId);
// Create intent
Activity activity = UnityPlayer.currentActivity;
Context context = activity.getApplicationContext();
Intent intent = new Intent(context, NotificationReceiver.class);
// Set intent params
intent.putExtra(LocalNotificationConstants.INTENT_ID_KEY, notificationId);
intent.putExtra(LocalNotificationConstants.INTENT_TITLE_KEY, title);
intent.putExtra(LocalNotificationConstants.INTENT_MESSAGE_KEY, message);
intent.putExtra(LocalNotificationConstants.INTENT_ACTION_KEY, UnityPlayerActivity.class.getName());
// Set notification time
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, sentAt);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
示例3: onResume
import com.unity3d.player.UnityPlayerActivity; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
// スキーマ取得
Uri uri = getIntent().getData();
// スキーマをシングルトンに保持
ApplicationCache.getInstance().customScheme = uri.toString();
// UnityのActivityを呼ぶ
Intent intent = new Intent(this, UnityPlayerActivity.class);
startActivity(intent);
finish();
}