public override void onReceive(Context arg0, Intent intent) { Log.d(TAG, "!@#!@ConsoleReceiver action:" + intent); if (intent.getAction() == CONSOLE_INTENT) { // Unity apps will not have a VrActivity, so they can only use console functions that are ok // with a NULL appPtr. if (activity is VrActivity) { nativeConsoleCommand(((VrActivity)activity).appPtr, intent.getStringExtra(CONSOLE_STRING_EXTRA)); } else { nativeConsoleCommand(((long)0), intent.getStringExtra(CONSOLE_STRING_EXTRA)); } } }
public static string getCommandStringFromIntent(Intent intent) { string commandStr = ""; if (intent != null) { commandStr = intent.getStringExtra(INTENT_KEY_CMD); if (commandStr == null) { commandStr = ""; } } return commandStr; }
public override int onStartCommand(Intent value0, int value1, int value2) { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ACTION); //registerReceiver(notifyServiceReceiver, intentFilter); // Send Notification var notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); var Title = "Notification!"; var TargetUri = "http://www.jsc-solutions.net"; if (value0.hasExtra("data0")) Title = value0.getStringExtra("data0"); if (value0.hasExtra("data1")) TargetUri = value0.getStringExtra("data1"); var myNotification = new Notification( // http://docs.since2006.com/android/2.1-drawables.php android.R.drawable.ic_menu_view, Title, //java.lang.JavaSystem.currentTimeMillis() java.lang.System.currentTimeMillis() ); var context = getApplicationContext(); var myIntent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(TargetUri)); var pendingIntent = PendingIntent.getActivity( getBaseContext(), 0, myIntent, Intent.FLAG_ACTIVITY_NEW_TASK ); myNotification.defaults |= Notification.DEFAULT_SOUND; myNotification.flags |= Notification.FLAG_AUTO_CANCEL; myNotification.setLatestEventInfo(context, Title, TargetUri, pendingIntent); notificationManager.notify(1, myNotification); this.stopSelf(); return 0; }
public static string getPackageStringFromIntent(Intent intent) { string packageStr = ""; if (intent != null) { packageStr = intent.getStringExtra(INTENT_KEY_FROM_PKG); if (packageStr == null) { packageStr = ""; } } return packageStr; }