gpt4 book ai didi

android - 我的 android 应用程序在不同的设备上崩溃

转载 作者:行者123 更新时间:2023-12-03 17:39:31 25 4
gpt4 key购买 nike

我已经在我的手机(LG Optimus NET)和 Galaxy Mini 上测试了我的应用程序,一切正常。但是当我想在更大屏幕的设备上测试它时,它会在启动时崩溃。我试过 S3 和 AllView(我真的不知道模型)。

我的 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.swipefragments"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:resizeable="true" android:anyDensity="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
<activity
android:name="com.example.swipefragments.MainActivity"
android:label="Stiai ca..."
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

主要 Activity :
public class MainActivity extends SherlockFragmentActivity {
static final int NUM_ITEMS = 550;

MyAdapter mAdapter;

ViewPager mPager;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);


requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
setContentView(R.layout.fragment_pager);

mAdapter = new MyAdapter(getSupportFragmentManager());

mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);

// Watch for button clicks.
Button button = (Button)findViewById(R.id.goto_first);
// button.getBackground().setColorFilter(0xFF0174DF, PorterDuff.Mode.MULTIPLY);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPager.setCurrentItem(0);
}
});
button = (Button)findViewById(R.id.goto_last);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPager.setCurrentItem(NUM_ITEMS-1);
}
});

button = (Button)findViewById(R.id.goto_random);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

Random r = new Random();
int i1=r.nextInt(529)+20;
mPager.setCurrentItem(i1);
}
});

button = (Button)findViewById(R.id.goto_about);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {

Toast.makeText(MainActivity.this, "Ciuboariu Florin, Ianuarie 2013", Toast.LENGTH_SHORT).show();
}
});
}

public static class MyAdapter extends FragmentPagerAdapter {
public MyAdapter(FragmentManager fm) {
super(fm);
}

@Override
public int getCount() {
return NUM_ITEMS;
}

@Override
public Fragment getItem(int position) {
return ArrayListFragment.newInstance(position);
}
}

public static class ArrayListFragment extends SherlockListFragment {
int mNum;

/**
* Create a new instance of CountingFragment, providing "num"
* as an argument.
*/
static ArrayListFragment newInstance(int num) {
ArrayListFragment f = new ArrayListFragment();

// Supply num input as an argument.
Bundle args = new Bundle();
args.putInt("num", num);
f.setArguments(args);

return f;
}

/**
* When creating, retrieve this instance's number from its arguments.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Random r = new Random();
// int i1=r.nextInt(70-1)+1;
// mNum = i1;
mNum = getArguments() != null ? getArguments().getInt("num") : 1;
}

/**
* The Fragment's UI is just a simple text view showing its
* instance number.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
View tv = v.findViewById(R.id.text2);
switch(mNum){
IMENSE HERE- deleted
}
return v;
}



@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

}




@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.i("FragmentList", "Item clicked: " + id);
}
}

日志猫:
01-14 21:42:13.969: E/dalvikvm-heap(17739): Creating VM heap of size start:2097152 max:536870912 base:0x4000c000
01-14 21:42:14.089: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:14.509: E/dalvikvm-heap(17750): Creating VM heap of size start:2097152 max:536870912 base:0x4000c000
01-14 21:42:14.749: I/ActivityManager(11125): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.swipefragments/.MainActivity } from pid 17750
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Launcher.java:1809:onPause()onPause
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:528:updateWallpaperOffset()1 firstEmptyScreen: 6
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:529:updateWallpaperOffset()1 getChildAt(firstEmptyScreen).getRight() 2240
01-14 21:42:14.769: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:536:updateWallpaperOffset()2 scrollRange: 1920, firstEmptyScreen: 6
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:542:updateWallpaperOffset()2 mCurDesktopState: 0, firstEmptyScreen: 6
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:547:updateWallpaperOffset()3 getScrollX: 960, mScrollX: 960
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:548:updateWallpaperOffset()3 getChildAt(firstEmptyScreen).getLeft(): 1920
01-14 21:42:14.779: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:554:updateWallpaperOffset()4 xOffset: 0.5
01-14 21:42:14.859: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:528:updateWallpaperOffset()1 firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:529:updateWallpaperOffset()1 getChildAt(firstEmptyScreen).getRight() 2240
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:536:updateWallpaperOffset()2 scrollRange: 1920, firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:542:updateWallpaperOffset()2 mCurDesktopState: 0, firstEmptyScreen: 6
01-14 21:42:14.929: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:547:updateWallpaperOffset()3 getScrollX: 960, mScrollX: 960
01-14 21:42:14.939: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:548:updateWallpaperOffset()3 getChildAt(firstEmptyScreen).getLeft(): 1920
01-14 21:42:14.959: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> ### onFinishInput
01-14 21:42:14.959: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> #### onStartInput restarting : false / inputType : 0
01-14 21:42:14.959: I/Flex(11205): <!>com.lge.provider.Andy_Flex 186<!> getMccCode numeric 22610
01-14 21:42:14.969: I/Flex(11205): <!>com.lge.provider.Andy_Flex 218<!> getMncCode numeric 22610
01-14 21:42:14.969: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> updateSIMInfo -> Old MCC : 226,Old MNC : 3 MCC = 226 MNC = 10
01-14 21:42:14.999: D/LGEHome(11472): <!>com.lge.launcher.HLog 26<!> Workspace.java:554:updateWallpaperOffset()4 xOffset: 0.5
01-14 21:42:15.139: I/ActivityManager(11125): <!>com.android.server.am.ActivityRecord 444<!> Displayed com.example.swipefragments/.MainActivity: +329ms
01-14 21:42:16.119: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] 0. mDataNetType: 8
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] curNetwork=22610 curHPLMN=22610
01-14 21:42:18.759: D/StatusBarPolicy(11197): [BRIGHTHY] getNationalRoaming=false Roaming=false
01-14 21:42:20.109: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:22.109: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:24.099: E/Tethering(11125): <!>com.android.server.connectivity.Tethering 278<!> active iface (usb0) reported as added, ignoring
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] 0. mDataNetType: 8
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] curNetwork=22610 curHPLMN=22610
01-14 21:42:30.759: D/StatusBarPolicy(11197): [BRIGHTHY] getNationalRoaming=false Roaming=false
01-14 21:42:30.829: V/DATA(11214): <!>com.android.internal.telephony.MMDataConnectionTracker 1820<!> [DCT] intent received :android.intent.action.SCREEN_OFF
01-14 21:42:30.839: V/FASTDORMANCTY(11214): <!>com.android.internal.telephony.LgeFastDormancyHandler 987<!> [UNKNOWN] intent received :android.intent.action.SCREEN_OFF
01-14 21:42:35.799: D/[Andy_Lock](11125): <!>com.android.internal.policy.impl.Andy_LockScreen 1556<!> getCurrentStatus simStateREADY
01-14 21:42:35.869: I/#LGIME(11205): <!>com.jungle.android.utils.Glog 35<!> Action : android.intent.action.CLOSE_SYSTEM_DIALOGS
01-14 21:42:35.879: E/WindowManager(11125): <!>com.android.internal.policy.impl.PhoneWindowManager 2211<!> bwk rotationForOrientationLw case return

谢谢你。

最佳答案

在哪些文件夹中放置了以下布局?

  • R.layout.fragment_pager
  • R.layout.fragment_pager_list

  • 在布局或布局-*??

    编辑:

    我认为问题出在这段代码中(与 SherlockFragmentActivity 有关:
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    尝试改用 xml(将其添加到 list 文件的 Activity 中):
     <activity
    android:name="com.example.swipefragments.MainActivity"
    android:label="Stiai ca..."
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:screenOrientation="portrait">

    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    希望能帮助到你!
    如果是这样,你知道该怎么做;)

    干杯!

    关于android - 我的 android 应用程序在不同的设备上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14325264/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com