setPackage() public méthode

public setPackage ( java arg0 ) : global::android.content.Intent
arg0 java
Résultat global::android.content.Intent
		public override Intent getLaunchIntentForPackage (string packageName)
		{
			if (!loaded_packages.ContainsKey (packageName))
				return null;

			XobotPackageInfo info = loaded_packages [packageName];

			if (info.Info.applicationInfo == null)
				throw new RuntimeException ("Cannot get ApplicationInfo from package.");
			if (info.Info.activities.Length < 1)
				throw new RuntimeException ("Package does not contain any Activity.");

			ActivityInfo ai = info.Info.activities [0];
			ai.applicationInfo.uid = android.os.Process.SYSTEM_UID;

			Intent intent = new Intent (Intent.ACTION_MAIN);
			intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
			intent.setPackage (packageName);
			intent.setClassName (info.Info.packageName, ai.name);

			return intent;
		}
        public override int onStartCommand(Intent value0, int value1, int value2)
        {
            #region Notify
            int counter = 0;
            Action<string, string, string> Notify =
                (Title, link, search) =>
                {
                    counter++;

                    var nm = (NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);


                    //var nn = new NotificationCompat
                    // see http://developer.android.com/reference/android/app/Notification.html
                    var notification = new Notification(
                        android.R.drawable.star_on,
                        Title,
                         java.lang.System.currentTimeMillis()
                    );

                    // ToClass is like GetTypeInfo
                    //var xmyIntent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse("http://youtube.com"));

                    //http://stackoverflow.com/questions/9860456/search-a-specific-string-in-youtube-application-from-my-app

                    // http://grokbase.com/t/gg/android-developers/123s02429a/use-marquee-on-notification-bar

                    Intent xmyIntent = new Intent(Intent.ACTION_SEARCH);
                    xmyIntent.setPackage("com.google.android.youtube");
                    xmyIntent.putExtra("query", search);

                    // https://code.google.com/p/android/issues/detail?id=82065
                    // http://stackoverflow.com/questions/11939018/scrolling-text-in-notification
                    xmyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    //startActivity(intent);

                    //var xmyIntent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(link));


 //[javac] W:\src\JVMCLRBroadcastLogger\__AndroidMulticast.java:165: error: bad operand type __Func_2< __f__AnonymousType_109_1_2<__NetworkInterface, Boolean>,__IEnumerable_1 < __UnicastIPAddressInformation >> for unary operator '!'
 //     [javac]             if (!__AndroidMulticast.CS___9__CachedAnonymousMethodDelegate10)
 //[javac] ^

                    var xpendingIntent
                      = PendingIntent.getActivity(
                          getBaseContext(),
                        0,
                        xmyIntent,
                        Intent.FLAG_ACTIVITY_NEW_TASK);


                    notification.setLatestEventInfo(
                        this,
                        Title,
                       Title,
                        xpendingIntent);

                    
                    // http://stackoverflow.com/questions/10402686/how-to-have-led-light-notification
                    //notification.defaults |= Notification.DEFAULT_VIBRATE;
                    //notification.defaults |= Notification.DEFAULT_SOUND;
                    //notification.defaults |= Notification.DEFAULT_LIGHTS;
                    //notification.defaults |= Notification.FLAG_SHOW_LIGHTS;


                    //new Notification.BigTextStyle(
                    
                    // http://androiddrawableexplorer.appspot.com/
                    nm.notify(counter, notification);

                    //context.ToNotification(
                    //      Title: Title,
                    //      Content: Title,

                    //      id: (int)java.lang.System.currentTimeMillis(),
                    //        icon: android.R.drawable.star_on,
                    //      uri: "http://my.jsc-solutions.net"
                    //  );
                };
            #endregion

            var intentFilter = new IntentFilter();
            intentFilter.addAction(ACTION);
            registerReceiver(notifyServiceReceiver, intentFilter);

            //            0001 02000006 AndroidServiceUDPNotification.AndroidActivity::< module >.SHA1c9cbee88a1edabb97eb411ca262280fe2fa18dd1@229018826
            //{ OwnerMethod = Int32 onStartCommand(android.content.Intent, Int32, Int32), DeclaringType = AndroidServiceUDPNotification.Activities.NotifyService }
            //            {
            //                exc = System.Security.VerificationException: Operation could destabilize the runtime.
            //                 at System.RuntimeMethodHandle.GetMethodBody(IRuntimeMethodInfo method, RuntimeType declaringType)
            //               at System.Reflection.RuntimeMethodInfo.GetMethodBody()
            //               at jsc.ILBlock..ctor(MethodBase SourceMethod) in x:\jsc.internal.git\compiler\jsc\CodeModel\ILBlock.cs:line 349

            Notify("awaiting for tv...", "http://youtube.com", "music");

            // http://developer.android.com/reference/android/net/wifi/WifiManager.html
            // http://developer.android.com/reference/android/net/wifi/WifiManager.html#createMulticastLock(java.lang.String)
            ((WifiManager)this.getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "ApplicationActivity").acquire();
            ((WifiManager)this.getSystemService(Context.WIFI_SERVICE)).createMulticastLock("ApplicationActivity").acquire();

            new JVMCLRBroadcastLogger.__AndroidMulticast(
                AtData:
                xmlstring =>
                {
                    // X:\jsc.svn\examples\javascript\chrome\apps\ChromeUDPNotification\ChromeUDPNotification\Application.cs

                    var xml = XElement.Parse(xmlstring);

                    if (xml.Value.StartsWith("Visit me at "))
                    {
                        // what about android apps runnning on SSL?
                        // what about preview images?
                        // do we get localhost events too?

                        var n = xml.Attribute("n");

                        var uri = "http://" + xml.Value.SkipUntilOrEmpty("Visit me at ");
                        var link = uri + "/results?search_query=" + n.Value;

                        Notify(n.Value, link, n.Value);
                    }
                }
            );



            return base.onStartCommand(value0, value1, value2);
        }