Application Error in FroYo & Gingerbread

- An anonymous answer is my answer that I solved this problem with .--

I am writing an Android application, everything works well in Honeycomb, but it doesn’t play very well on my FroYo and Gingerbread devices (contrary to what you expect from yourself).

Here is the code that in my opinion is causing the problem:

@Override
protected void onStart() {
    int versionNumber = Integer.valueOf(android.os.Build.VERSION.SDK);
    if (versionNumber == 11) {
        super.onStart();
        ActionBar actionBar = this.getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}

Here I implement the ActionBar ability to connect to the house, I added the versionNumber variable, because I believed that the absence of an ActionBar in pre-Honyecomb devices causes a problem when starting this operation, but it still crashes and I believe that this is a problem, although I terrible with debugging and don't understand anything that I give logcat.

Edit: logcat - I hope I have the correct partition ?!

08-20 17: 21: 41.326: WARN/ActivityManager (2707): com.squirculardesign.android.pixel/. 08-20 17: 21: 41.346: INFO/dalvikvm (4059): com.squirculardesign.android.pixel.About.getActionBar, com.squirculardesign.android.pixel.About.onStart 08-20 17: 21: 41.346: WARN/dalvikvm (4059): VFY: 54: Lcom/squirculardesign/android/pixel/About;.getActionBar() Landroid//ActionBar; 08-20 17: 21: 41.346: DEBUG/dalvikvm (4059): VFY: 0x6e 0x0011 08-20 17: 21: 41.346: DEBUG/dalvikvm (4059): VFY: 0x0014-0018 Lcom/squirculardesign/android/pixel/About;.onStart() V 08-20 17: 21: 41.386: INFO/ALSAModule (2588): ALSA PLAYBACK hifi 08-20 17: 21: 41.386: WARN/AudioFlinger (2588): 108 , 3 , 0x5e758 08-20 17: 21: 41.406: DEBUG/dalvikvm (4059): GC_EXTERNAL_ALLOC 38K, 52% 2621K/5379K, 190K/518K, 36 08-20 17: 21: 41.596: INFO/AudioFlinger (2588): Type (0, 1) 1 08-20 17: 21: 41.596: DEBUG/AudioHardwareYamaha (2588): AudioStreamOut:: SetParameters (keyValuePairs = "stop_output_streamtype = 1" ) 08-20 17: 21: 42.096: ERROR/yamaha:: media:: (2588): SalesCode = OPS 08-20 17: 21: 42.671: / (2707): write_int: /sys/devices/virtual/misc/melfas _touchkey/, 2 08-20 17: 21: 42.671: WARN/PowerManagerService (2707): 0x7- > 0x3 | 0x3 08-20 17: 21: 42.671: INFO/PowerManagerService (2707): Ulight 7- > 3 | 0 08-20 17: 21: 42.671: DEBUG/PowerManagerService (2707): setLightBrightness: mButtonLight: 0 08-20 17: 21: 43.666: INFO/ALSAModule (2588): ALSA PLAYBACK hifi 08-20 17: 21: 44.086: ERROR/yamaha:: media:: (2588): SalesCode = OPS 08-20 17: 21: 51.181: WARN/ActivityManager (2707): , ! 08-20 17: 21: 51.336: WARN/ActivityManager (2707): - HistoryRecord {40a6f0a8 com.squirculardesign.android.pixel/.About} 08-20 17: 21: 56.456: DEBUG/dalvikvm (2929): GC_EXPLICIT 672K, 53% 3917K/8327K, 12588K/12670K, 121 08-20 17: 22: 01.876: INFO/StatusBarPolicy (2834): onSignalStrengthsChanged 08-20 17: 22: 04.006: DEBUG/BatteryService (2707): 08-20 17: 22: 04.011: /BatteryService (2707): TMU = 0 08-20 17: 22: 04.011: DEBUG/BatteryService (2707): updateBattery level: 79 : 100 : 2 : 2 : : 4050 : 270: Li-ion : USB: true icon: 17302229

+5
3

, , , , - ...

, , :

//Sets the icon to 'go home' button
@Override
protected void onStart() {
    int versionNumber = Integer.valueOf(android.os.Build.VERSION.SDK);
    if (versionNumber >= 11) {
            super.onStart();
            ActionBar actionBar = this.getActionBar();
            actionBar.setDisplayHomeAsUpEnabled(true);
    }
    else {
            super.onStart();
    }
}

Gingerbread, FroYo, , super.onStart(); , .

, / , : ActionBar , ActionBar Honeycomb, UI, . Ac

+6

, versionNumber? , if - . , versionNumber.

int versionNumber = android.os.Build.VERSION.SDK_INT
+3

:

public boolean onOptionsItemSelected(MenuItem item) {

if(item.getItemId()==android.R.id.home){
    Intent intent = new Intent(this, YourHomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    return true;
}

You need to declare "item.getItemId () == android.R.id.home" and ten "give" the name of your home activity "YourHomeActivity.class". Now when someone clicks the up button, you will be redirected to your home activity, "YourHomeActivity.class".

0
source

All Articles