Saturday, January 25, 2014

Neighborhoods broadcast issues


            
Novice neighborhoods broadcast problem.
InstallReceiver receiver = new InstallReceiver ();
IntentFilter filter = new IntentFilter ();
registerReceiver (receiver, filter);

class InstallReceiver extends BroadcastReceiver {
@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
if (intent.getAction (). equals (Intent.ACTION_PACKAGE_ADDED)) {
String packName = intent.getDataString () substring (8);.

System.out.println (packName);

}
}
}

What is the problem you wrote, did not reflect the final broadcast ah.
Reply:
Registered receiver to determine whether the dynamic success.
Reply:
IntentFilter filter = new IntentFilter (Intent.ACTION_PACKAGE_ADDED)
Reply:
cited a floor luozhongzhu reply:
registered receiver to determine whether the dynamic success.

How this determination ah. .
Reply:
reference to the third floor u011545493 reply:
Quote: references to a floor luozhongzhu reply:

Registered receiver to determine whether the dynamic success.

How this determination ah. .

You are using the manual registration method, you can first determine whether increased ACTION filter, see I give you the code
Reply:
references, 4th Floor sinom reply:
Quote: references to the third floor u011545493 reply:

Quote: references to a floor luozhongzhu reply:

Registered receiver to determine whether the dynamic success.

How this determination ah. .

You are using the manual registration method, you can first determine whether increased ACTION filter, see I give you the code

I tried the code you gave me, or did not come out ah. .
Reply:
androidMANIfest.xml code put out look
Reply:
reference to the 6th floor siyehua reply:
androidMANIfest.xml code put out look

Amount, the authority to add it?
Reply:
reference to the 7th floor u011545493 reply:
Quote: references to the 6th floor siyehua reply:

androidMANIfest.xml code put out look

Amount, the authority to add it?

Must first register here, then need to add permissions must add permissions
But you are dynamic registration, you do not register here
Reply:
reference to the 8th floor siyehua reply:
Quote: references to the 7th floor u011545493 reply:

Reply Quote 6th Floor siyehua of::
Quote

androidMANIfest.xml code put out look

Amount, the authority to add it?

Must first register here, then need to add permissions must add permissions
But you are dynamic registration, you need to register

hereYes, ah, I do not need registration manifest ah, I see no need to add anything like this permission, do not know where the problems. .
Reply:
I know, I recently wrote a lot of radio.
I usually write so
private InstallReceiver receiver;
private IntentFilter filter;

onCreate () {
receiver = new InstallReceiver ();
this.registerReceiver (receiver, filter)
}

class InstallReceiver extends BroadcastReceiver {
public InstallReceiver () {
filter = new IntentFilter ();
filter.addAction (Intent.ACTION_PACKAGE_ADDED);
}

@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
if (intent.getAction (). equals (Intent.ACTION_PACKAGE_ADDED)) {
String packName = intent.getDataString () substring (8);.

System.out.println (packName);

}
}
}

ondestory () {
this.unregistReceiver (receiver);
}

Your filter did not add action here
Reply:
reference to the 10th floor y1204234297 reply:
I know, I recently wrote a lot of radio.
I usually write so
private InstallReceiver receiver;
private IntentFilter filter;

onCreate () {
receiver = new InstallReceiver ();
this.registerReceiver (receiver, filter)
}

class InstallReceiver extends BroadcastReceiver {
public InstallReceiver () {
filter = new IntentFilter ();
filter.addAction (Intent.ACTION_PACKAGE_ADDED);
}

@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
if (intent.getAction (). equals (Intent.ACTION_PACKAGE_ADDED)) {
String packName = intent.getDataString () substring (8);.

System.out.println (packName);

}
}
}

ondestory () {
this.unregistReceiver (receiver);
}

Here you do not add filter action

Amount is still the same, the problem is actually upstairs has let me add too, still the same. .
This notification means that the application will play packName slightly Bahrain? But that did not come out ah,
Reply:
From the top, and then seek expert help facie ah.
Reply:
reference to the 12th floor u011545493 reply:
from the top, and then seek expert help facie ah.

I did not carefully look at your code, I found you have not solved, you're missing a step, that you here
IntentFilter filter = new IntentFilter ();
registerReceiver (receiver, filter);
Should be so written:
 IntentFilter filter = new IntentFilter (); 
/ / Put this Action added
filter.addAction (Intent.ACTION_PACKAGE_ADDED);
registerReceiver (receiver, filter);

Reply:
Upstairs say to add this: filter.addAction (Intent.ACTION_PACKAGE_ADDED);

Almost, you look at the demo on sdk broadcast this one, compare their
Reply:
reference to the 11th floor u011545493 reply:
Quote: references to the 10th floor y1204234297 reply:

I know, I recently wrote a lot of radio.
I usually write so
private InstallReceiver receiver;
private IntentFilter filter;

onCreate () {
receiver = new InstallReceiver ();
this.registerReceiver (receiver, filter)
}

class InstallReceiver extends BroadcastReceiver {
public InstallReceiver () {
filter = new IntentFilter ();
filter.addAction (Intent.ACTION_PACKAGE_ADDED);
}

@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
if (intent.getAction (). equals (Intent.ACTION_PACKAGE_ADDED)) {
String packName = intent.getDataString () substring (8);.

System.out.println (packName);

}
}
}

ondestory () {
this.unregistReceiver (receiver);
}

Here you do not add filter action

Amount is still the same, the problem is actually upstairs has let me add too, still the same. .
This notification means that the application will play packName slightly Bahrain? But that did not come out ah,,


You see log, usually with log.i (TAG, name); Look, if System.out.println (name); want to add the filter in logcat as, name: System.out TAG: System.out see here print the results, the console can not see, do not know will not be a problem. Or print the next level of data to see the broadcast has not received, or data problems, and there did not send broadcasts.

Reply:
cited 15 floor y1204234297 reply:
Quote: references to the 11th floor u011545493 reply:

Quote: references to the 10th floor y1204234297 reply:

I know, I recently wrote a lot of radio.
I usually write so
private InstallReceiver receiver;
private IntentFilter filter;

onCreate () {
receiver = new InstallReceiver ();
this.registerReceiver (receiver, filter)
}

class InstallReceiver extends BroadcastReceiver {
public InstallReceiver () {
filter = new IntentFilter ();
filter.addAction (Intent.ACTION_PACKAGE_ADDED);
}

@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
if (intent.getAction (). equals (Intent.ACTION_PACKAGE_ADDED)) {
String packName = intent.getDataString () substring (8);.

System.out.println (packName);

}
}
}

ondestory () {
this.unregistReceiver (receiver);
}

Here you do not add filter action

Amount is still the same, the problem is actually upstairs has let me add too, still the same. .
This notification means that the application will play packName slightly Bahrain? But that did not come out ah,,


You see log, usually with log.i (TAG, name); Look, if System.out.println (name); want to add the filter in logcat as, name: System.out TAG: System.out see here print the results, the console can not see, do not know will not be a problem. Or print the next level of data to see the broadcast has not received, or data problems, and there did not send broadcasts.

Well, I registered in the manifest, and be able to successfully play out, this registration code will not work. . . Should not be the reason you say it. . Feel should be registered wrong, do not know what wrong. .
Reply:
To accept this system broadcasts not only to add permissions, plus action dynamic registration, but also add setData (); in this property android configuration file: scheme = "package"
Reply:
cited 17 floor shaoyangtangsong reply:
to accept this system broadcasts not only to add permissions, plus action dynamic registration, but also add setData (); in This configuration file attributes android: scheme = "package"

You're like a little truth, dynamic registration should android: scheme = "package" added Where ah?
Reply:
Plus filter.addDataScheme ("package"); After resolving the matter, thank you ah!

No comments:

Post a Comment