我从版本17到21.1.2安装了所有Android SDK Build-tools.我可以毫无问题地删除旧包吗?

我让用户在我的应用程序中选择一个联系人,然后将其显示在主屏幕小部件上,但是照片没有显示,我不知道出了什么问题.
这就是我获取照片的参考方式:
...
Cursor c = null;
try {
c = getContentResolver().query(uri, new String[] {
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.PHOTO_ID },
null, null, null);
if (c != null && c.moveToFirst()) {
String number = c.getString(0);
int type = c.getInt(1);
String name = c.getString(2);
int photo = c.getInt(3);
showSelectedNumber(type, number, name, photo);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我显示它的方式:
public void showSelectedNumber(int type, String number, String name, int photo) {
mAppWidgetPrefix.setText(name);
pickedNumber.setText(number);
pickedPhoto.setImageResource(photo);
}
Run Code Online (Sandbox Code Playgroud)
为什么不起作用?
我有一个有趣的问题——至少对我来说是这样。我不希望我的应用程序在菜单中有一个启动器图标 - 我远程启动它,我不想在菜单中显示它。
我该如何解决?
我的想法是从清单中删除以下内容:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
这会解决我的问题吗?
我的程序(实际上不是我的,我只是想修复这个错误)在大多数手机上运行正常,但它不能在索尼Xperia P上启动.
当我启动该程序时,会出现以下消息:
应用程序意外停止.
该应用程序在此手机上也没有启动器图标(仅限默认图标).
错误日志说:
java.lang.RuntimeException: unable to start Activity
android.view.InflateException: Binary XML file line #16: error inflating class android.view.ImageView
Run Code Online (Sandbox Code Playgroud)
应用程序调用时出现错误消息:
setContentView(R.layout.menu_0_splash);
Run Code Online (Sandbox Code Playgroud)
我注意到可绘制资源是针对以下分辨率定义的:
1024x600 320x240 400x240 480x320 800x480 854x480
这款手机的电话是960x540,所以我最好的问题是它也应该是dafault资源.
可能是什么问题呢?
布局文件(现在复制/粘贴-d):
<?xml version = "1.0"
encoding = "utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/m0_relativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gradient_green" >
<ImageView #this is the problematic line
android:id="@+id/arrow_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/m0_arrow_top_margintop"
android:src="@drawable/splash_arrow_top" />
<ImageView
android:id="@+id/arrow_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="@dimen/m0_arrow_bottom_marginbottom"
android:src="@drawable/splash_arrow_bottom" />
<ImageView
android:id="@+id/belt_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/splash_belt_top" …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,我用一个远程启动它broadcast receiver.我使用这种方法将其隐藏在app抽屉中:
public static void hideFromAppDrawer(Context c) {
ComponentName componentToDisable = new ComponentName(
"mypackage", "mypackage.MyMainActivity");
c.getPackageManager().setComponentEnabledSetting(componentToDisable,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
Run Code Online (Sandbox Code Playgroud)
但是在隐藏之后,(我隐藏了laucher活动,之后我想远程启动相同的活动)应用程序无法启动.日志说:
03-27 15:00:53.494: E/AndroidRuntime(23392): FATAL EXCEPTION: main
03-27 15:00:53.494: E/AndroidRuntime(23392): java.lang.RuntimeException: Unable to start receiver mypackage.receivers.myReceiver: android.content.ActivityNotFoundException: Unable to find explicit activity class {mypackage/mypackage.MyMainActivity}; have you declared this activity in your AndroidManifest.xml?
03-27 15:00:53.494: E/AndroidRuntime(23392): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2383)
Run Code Online (Sandbox Code Playgroud)
broadcast receiver's onReceive()当我尝试启动活动时,错误在于方法:
context.startActivity(i);
03-27 15:00:53.494: E/AndroidRuntime(23392): at ... .onReceive(MyReceiver.java:36)
Run Code Online (Sandbox Code Playgroud)
可能是什么问题,如何在应用程序抽屉中隐藏应用程序时启动它?