views:

74

answers:

1

I have people complaining my application gets FC when they launch it (meanwhile others never had a single problem). Here is my full activity source. Since it happens on devices I don't own I can not fix it. From what they tell me it doesn't work on: Motorola Blackflip, Motorola Dext, Motorola CLIQ XT. Guess Motorola doesn't like my app after all...

Could it be that I allow a minSdkVersion="3"? I tested 1.5 on the emulator and worked fine...

Thank you in advance for your responses.

public class workit extends Activity implements OnClickListener {

 Button yay;
 Button yay0;
 Button yay1;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);

        yay = (Button) findViewById(R.id.gostart);
        yay.setOnClickListener(this);
        yay0 = (Button) findViewById(R.id.dontstart);
        yay0.setOnClickListener(this);
        yay1 = (Button) findViewById(R.id.exit);
        yay1.setVisibility(ImageView.GONE);


        ImageView inizio = (ImageView)findViewById(R.id.start);                                        
        inizio.setVisibility(ImageView.VISIBLE);
        inizio.setBackgroundResource(R.drawable.start);
    }

 public void onClick(View v) {
  // TODO Auto-generated method stub
     if (v == yay0) {
      finish();
  }
     if (v == yay) {
   ImageView inizio = (ImageView)findViewById(R.id.start);
   inizio.setVisibility(ImageView.GONE);
   WebView work = new WebView(this);
   setContentView(work);
   work.loadUrl("file:///android_asset/index1.html");
   work.setWebViewClient( new work()); 
   work.setBackgroundColor(0);
   work.getSettings().setBuiltInZoomControls(true);
   work.getSettings().setDefaultZoom(ZoomDensity.FAR);
  }
     if (v == yay1) {
      finish();
  }
    }
    private class work extends WebViewClient {     
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("exit.html")) {
             // TODO: do what you have to do
             finish();
            }
            view.loadUrl(url);
            return true;
        }
    } 
}
+1  A: 

Your best bet is to ask somebody to send you the LogCollector output (in my experience, users are very happy to provide you information to debug problems. There are some really cool people out there). That should give you a callstack, and information on what kind of exception you triggered (NullPointerException, etc).

Next up - what are you building your app against? There should be an "Android x.x" entry in your project structure somewhere. If you're building something that is supposed to run on Android 1.5, then make sure you actually build against 1.5. You CAN build against 2.0 if you want, but if you need to use 2.0-specific functions, you'll have to encapsulate them properly. (This has been explained in detail on stackoverflow several times.)

On an unrelated note - I recommend more informative variable names. "yay0" doesn't mean anything to anyone who hasn't been working intimately with the code for a while.

EboMike
Thank you for your answer, my target is 2.2 actually. Which way would you recommend for the users to send me the LogCollector output? How should I guide them through?
triump
Ask them to install the LogCollector app and run it right after your app crashes. It will automatically prepare a mail that they can send to you. As for the build version - just for fun, try setting it to 1.5 and see if it still compiles. It's okay to target 2.2 so you can support installation on SD card, but again - make sure you don't use 1.6+ API calls if you want to support 1.5 devices.
EboMike
This is the answer!! work.getSettings().setDefaultZoom(ZoomDensity.FAR); can't be compiled in 1.5 and 1.6. Now I just have to find a way to have my webview zoomed FAR without ZoomDensity.
triump
Check out this post: http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html
EboMike
Very helpful thank you!
triump