这是我目前的代码,但我仍然无法获得手机上所有应用的列表.有谁看到我做错了什么?
public class GetAppList extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
List<PackageInfo> appListInfo1 = this.getPackageManager()
.getInstalledPackages(0);
JSONArray ja = new JSONArray();
try {
HttpClient httpclient = new DefaultHttpClient();
Object sendDataUrl = null;
HttpPost request = new HttpPost(sendDataUrl.toString());
List<NameValuePair> params = new ArrayList<NameValuePair>();
ContextWrapper context = null;
PackageManager pm = context.getPackageManager();
List<PackageInfo> appListInfo = pm.getInstalledPackages(0);
for (PackageInfo p : appListInfo) {
if (p.applicationInfo.uid > 10000) { …Run Code Online (Sandbox Code Playgroud) 她就是我想要完成的事情:
我是这样做的:
AndroidManifest.xml中
<receiver
android:name=".MyBroadcastReceiver" >
<intent-filter
android:label="select my app">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
MyBroadcastReceiver.java
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
//Some simple code
Toast.makeText(arg0, "My Receiver is cool", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,我的应用程序没有显示在共享列表中.
为什么我合作BroadcatReceivers而不合作Activities?因为我不想要任何UI,我认为这就是为什么我们有接收器(纠正我的PLZ)
我做得对吗?
android ×2