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


Java UnityPlayerActivity类代码示例

本文整理汇总了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);
}
 
开发者ID:Agasper,项目名称:unity-android-notifications,代码行数:21,代码来源:UnityNotificationActionHandler.java

示例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);
}
 
开发者ID:tenjikinc,项目名称:AndroidUnityPlugin,代码行数:34,代码来源:NotificationUtil.java

示例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();
}
 
开发者ID:tenjikinc,项目名称:AndroidUnityPlugin,代码行数:15,代码来源:IntentReceiveActivity.java


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