我有一个很大的问题。当我在我的三星Galaxy Tab 3上使用JELLY_BEAN安卓版本在usb调试模式下安装我的应用程序时,它崩溃的Touchwiz和我无法在我的设备上做任何事情。奇怪的是,在Genymotion虚拟设备上它表现得很好。
此处截图:screenshot
这是我的laucher活动:
public class ProjectActivity extends FragmentActivity {
private boolean hasTwoPanes;
private String TAG = "ProjectActivity";
private int parent_id = 0;
private long filter_id = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.acitivity_projects_list);
getActionBar().setTitle(R.string.projects);
if(savedInstanceState == null)
newFragment(parent_id);
else {
parent_id = savedInstanceState.getInt("parent_id");
filter_id = savedInstanceState.getLong("filter_id");
}
}
public void newFragment(int parent_id){
Bundle state = new Bundle();
state.putInt("parent_id", parent_id);
ProjectsListFragment list_fragment = new ProjectsListFragment();
this.parent_id = parent_id;
list_fragment.parent_id = parent_id;
list_fragment.setArguments(state);
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.replace(R.id.list, list_fragment, "" + parent_id);
transaction.addToBackStack("" + parent_id);
transaction.commit();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("parent_id", parent_id);
outState.putLong("filter_id", filter_id);
}
@Override
public void onBackPressed() {
FragmentManager manager = getFragmentManager();
if(manager.getBackStackEntryCount() < 2){
finish();
return;
}
manager.popBackStackImmediate();
}
@Override
protected void onResume() {
super.onResume();
FragmentManager manager = getFragmentManager();
setFilter(filter_id, (ProjectsListFragment) manager.findFragmentByTag(manager.getBackStackEntryAt(manager.getBackStackEntryCount() - 1).getName()));
}
@Override
protected void onPause() {
super.onPause();
DatabaseHelper.getDatabase(ProjectActivity.this).close();
}
protected void setFilter(long id, ProjectsListFragment list_fragment) {
SQLiteDatabase mDatabase = DatabaseHelper.getDatabase(ProjectActivity.this);
((ProjectsListAdapter)list_fragment.getListAdapter()).changeCursor(DatabaseManager.getProjectsCursor(mDatabase, list_fragment.parent_id, (int)id));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.project_action_bar, menu);
menu.findItem(R.id.new_project).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
startActivity(new Intent(ProjectActivity.this, NewProjectActivity.class));
return false;
}
});
menu.findItem(R.id.new_sub_unit).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if(getFragmentManager().getBackStackEntryCount() == 1)
startActivity(new Intent(ProjectActivity.this, NewProjectActivity.class));
else{
Intent intent = new Intent(ProjectActivity.this, NewSubunitActivity.class);
intent.putExtra("parent_id", parent_id);
startActivityForResult(intent, NewSubunitActivity.ADD_SUB_UNITS);
}
return false;
}
});
menu.findItem(R.id.menu_projects).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
startActivity(new Intent(ProjectActivity.this, ProjectActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
return false;
}
});
menu.findItem(R.id.menu_filter).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
View view = LayoutInflater.from(ProjectActivity.this).inflate(R.layout.simple_list_dialog, null);
final ListView list = (ListView)view.findViewById(R.id.listView1);
final SimpleDialogListAdapter adapter = new SimpleDialogListAdapter(ProjectActivity.this, DatabaseManager.getStatusCursor(DatabaseHelper.getDatabase(ProjectActivity.this)), SimpleDialogListAdapter.STATUS_FILTER);
View header = LayoutInflater.from(ProjectActivity.this).inflate(R.layout.filter_row, null);
((TextView)header.findViewById(R.id.name_edit_txt)).setText("Default");
((TextView)header.findViewById(R.id.color_btn)).setBackgroundColor(getResources().getColor(R.color.white));
list.addHeaderView(header);
list.setAdapter(adapter);
AlertDialog.Builder builder = new AlertDialog.Builder(ProjectActivity.this);
builder.setTitle(R.string.filter);
builder.setView(view);
final AlertDialog filter_dialog = builder.create();
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long id) {
position--;
FragmentManager manager = getFragmentManager();
ProjectsListFragment list_fragment = (ProjectsListFragment) manager.findFragmentByTag(manager.getBackStackEntryAt(manager.getBackStackEntryCount() - 1).getName());
if(position >= 0) {
setFilter(filter_id = id, list_fragment);
}
else {
setFilter(filter_id = -1, list_fragment);
}
((ProjectsListAdapter)list_fragment.getListAdapter()).notifyDataSetChanged();
filter_dialog.dismiss();
}
});
filter_dialog.show();
return false;
}
});
return true;
}
}
public class ProjectsListFragment extends ListFragment {
private String TAG = "ProjectsListFragment";
public View header;
public int parent_id = 0;
public ProjectsListFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
};
@Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
if(getArguments() != null)
parent_id = getArguments().getInt("parent_id");
header = LayoutInflater.from(getActivity()).inflate(R.layout.project_list_header, null);
((TextView)header.findViewById(R.id.header_txt)).setText(DatabaseManager.getProjectPath(DatabaseHelper.getDatabase(getActivity()), parent_id));
setListAdapter(null);
getListView().addHeaderView(header);
setListAdapter(new ProjectsListAdapter(getActivity(), parent_id, 0));
}
@Override
public void onListItemClick(ListView list, View view, int position, long id) {
super.onListItemClick(list, view, position, id);
if(position == 0)
return;
Bundle state = new Bundle();
parent_id = ((Cursor)getListAdapter().getItem(position)).getInt(0);
state.putInt("parent_id", parent_id);
((ProjectActivity)getActivity()).newFragment(parent_id);
}
}
public class ProjectsListAdapter extends CursorAdapter{
private Activity mActivity;
private LayoutInflater mInflater;
private String TAG = "ProjectsListAdapter";
private SimpleDateFormat simple_format;
public ProjectsListAdapter(Activity mContext, int parent_id, int flags) {
super(mContext, DatabaseManager.getProjectsCursor(DatabaseHelper.getDatabase(mContext), parent_id, 0), flags);
this.mActivity = mContext;
mInflater = LayoutInflater.from(mContext);
this.simple_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
}
@Override
public void bindView(final View row, final Context mContext, final Cursor mCursor){
TextView main_txt = (TextView) row.findViewById(R.id.main_txt);
TextView mod_txt = (TextView) row.findViewById(R.id.sub_txt);
//TextView sub_txt = (TextView) row.findViewById(R.id.sub_txt);
Button status_btn = (Button) row.findViewById(R.id.status_btn);
ImageButton options_btn = (ImageButton) row.findViewById(R.id.options_btn);
final int index = mCursor.getInt(0);
options_btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(final View v) {
row.setBackgroundColor(mContext.getResources().getColor(R.color.light_grey));
rotate(0, 180, v);
Point point = new Point();
mActivity.getWindowManager().getDefaultDisplay().getSize(point);
Dialog dialog = Dialogs.getProjectSpinnerDialog(mContext, index, point.x);
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
rotate(180, 360, v);
changeCursor(DatabaseManager.getProjectsCursor(DatabaseHelper.getDatabase(mContext), mCursor.getInt(1), 0));
notifyDataSetChanged();
row.setBackgroundColor(Color.WHITE);
}
});
dialog.show();
}
});
main_txt.setText(mCursor.getString(2));
mod_txt.setText(simple_format.format(new Date(mCursor.getLong(8))).toString());
//sub_txt.setText(mCursor.getFloat(3) + "%");
status_btn.setText(mCursor.getString(5));
int color = mCursor.getInt(7);
if(color == 0)
color = -1;
int gradient_start = Color.argb(133, Color.red(color), Color.green(color), Color.blue(color));
int gradient_end = Color.argb(230, Color.red(color), Color.green(color), Color.blue(color));
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.BL_TR, new int[] {gradient_start, gradient_end});
gd.setCornerRadius(0f);
row.setBackground(gd);
}
@Override
public Object getItem(int position) {
return super.getItem(position - 1);
}
@Override
public View newView(Context mContext, Cursor mCursor, ViewGroup mGroup) {
View row = mInflater.inflate(R.layout.projects_row, null);
bindView(row, mContext, mCursor);
return row;
}
public static void rotate(float from_degree, float to_degree, View view) {
final RotateAnimation rotateAnim = new RotateAnimation(from_degree, to_degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(500);
rotateAnim.setFillAfter(true);
view.startAnimation(rotateAnim);
}
}
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(1) returned 0
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(30) returned 0
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(4) returned 0
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(3) returned 0
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(4) returned 0
06-15 22:02:55.242: D/skia(25588): ---- fAsset->read(6) returned 0
06-15 22:02:55.242: D/skia(25588): --- SkImageDecoder::Factory returned null
06-15 22:02:55.242: W/PackageManager(25588): Failure retrieving icon 0x7f02000a in package com.holubowski.projectmanager
06-15 22:02:55.242: W/PackageManager(25588): java.lang.NullPointerException
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ApplicationPackageManager.putCachedIcon(ApplicationPackageManager.java:904)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:661)
06-15 22:02:55.242: W/PackageManager(25588): at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:151)
06-15 22:02:55.242: W/PackageManager(25588): at android.content.pm.ComponentInfo.loadDefaultIcon(ComponentInfo.java:167)
06-15 22:02:55.242: W/PackageManager(25588): at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:156)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ApplicationPackageManager.getActivityIcon(ApplicationPackageManager.java:681)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:252)
06-15 22:02:55.242: W/PackageManager(25588): at java.lang.reflect.Constructor.constructNative(Native Method)
06-15 22:02:55.242: W/PackageManager(25588): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.createView(LayoutInflater.java:593)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-15 22:02:55.242: W/PackageManager(25588): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3298)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3358)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:314)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.Activity.setContentView(Activity.java:1920)
06-15 22:02:55.242: W/PackageManager(25588): at com.holubowski.activitys.ProjectActivity.onCreate(ProjectActivity.java:47)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.Activity.performCreate(Activity.java:5185)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2154)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ActivityThread.access$700(ActivityThread.java:146)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1260)
06-15 22:02:55.242: W/PackageManager(25588): at android.os.Handler.dispatchMessage(Handler.java:99)
06-15 22:02:55.242: W/PackageManager(25588): at android.os.Looper.loop(Looper.java:137)
06-15 22:02:55.242: W/PackageManager(25588): at android.app.ActivityThread.main(ActivityThread.java:4949)
06-15 22:02:55.242: W/PackageManager(25588): at java.lang.reflect.Method.invokeNative(Native Method)
06-15 22:02:55.242: W/PackageManager(25588): at java.lang.reflect.Method.invoke(Method.java:511)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043)
06-15 22:02:55.242: W/PackageManager(25588): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
06-15 22:02:55.242: W/PackageManager(25588): at dalvik.system.NativeStart.main(Native Method)
06-15 22:02:55.304: D/AbsListView(25588): Get MotionRecognitionManager
06-15 22:02:55.500: D/libEGL(25588): loaded /system/lib/egl/libEGL_MRVL.so
06-15 22:02:55.507: D/libEGL(25588): loaded /system/lib/egl/libGLESv1_CM_MRVL.so
06-15 22:02:55.523: D/libEGL(25588): loaded /system/lib/egl/libGLESv2_MRVL.so
06-15 22:02:55.539: D/GC(25588): <tid=25588> OES20 ===> GC Version : GC Ver-988-JB-R4-RC2-GC20
06-15 22:02:55.562: D/OpenGLRenderer(25588): Enabling debug mode 0
06-15 22:02:55.671: D/dalvikvm(25588): GC_CONCURRENT freed 222K, 14% free 7585K/8775K, paused 12ms+2ms, total 50ms
找到原因并修复它!
对于任何有类似问题的人,在我的情况下,问题会产生一个图标,我不知道为什么,但它似乎已损坏,并在应用程序启动时使nullpointer异常,然后touchwiz正常(不是调试模式)启动吓坏了。 要修复它,只需删除此png并添加新内容。
答案 0 :(得分:0)
在以下每个文件夹中添加适当尺寸的启动器图标(png,32位):
- mdpi:48x48
- hdpi:72x72
- xhdpi:96x96
- xxhdpi:144x144
- xxxhdpi:192x192
这阻止了三星的touchwiz家庭崩溃