SDK 2.0: wrong behaviour after convertion from SDK1.6 - please help!

by Evgeny V » Sun, 29 Nov 2009 01:22:31 GMT


Sponsored Links
 Hi!

I got infinit loop when trying to run activity which creating dialog.
Before I'm pressing the dialog button OK or Cancel button the system is
startong my tab main activity again.
It worked fine in all previouse versions.
 The log report:
*11-28 16:59:38.607: WARN/UsageStats(59): Something wrong here, didn't
expect evgeny.converter to be resumed
11-28 17:12:06.498: ERROR/WindowManager(269): android.view.WindowLeaked:
Activity evgeny.converter.TabMain has leaked window
com.android.internal.policy.impl.phonewindow$decorv...@43cfd4f0 that was
originally added here
*
Thanks in advance,
Evgeny

The code is as following:
Launcher code:
  SharedPreferences _State;
     @Override
     protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

         final TabHost tabHost = getTabHost();

         tabHost.addTab(tabHost.newTabSpec("tabMeasures")
                 .setIndicator(res.getString(R.string.tab_measures_title),
                 res.getDrawable(R.drawable.measures_tab_32))
                 .setContent(new Intent(this, MeasuresMain.class)));

         tabHost.addTab(tabHost.newTabSpec("tabClothes")
                 .setIndicator(res.getString(R.string.tab_clothes_title),
                 res.getDrawable(R.drawable.clothes_tab_40))
                 .setContent(new Intent(this, ClothesMain.class)));
         tabHost.addTab(tabHost.newTabSpec("tabSettings")
                 .setIndicator(res.getString(R.string.tab_settings_title),
                 res.getDrawable(R.drawable.settings_tab_40))
                 .setContent(new Intent(this,
ConverterViewSettings.class)));

         tabHost.setBackgroundResource(R.drawable.background_main);

         _State = getSharedPreferences("Settings", MODE_WORLD_READABLE |
MODE_WORLD_WRITEABLE );
         if(_State.getBoolean(ConverterUtil.EVG_IS_SHOW_LICENSE_AGREEMENT,
true))
          showDialog(1);

     }

@Override
     protected Dialog onCreateDialog(int id)
     {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setPositiveButton(R.string.lblButtonAgree, new
DialogInterface.OnClickListener()
      {
       public void onClick(DialogInterface dialog, int whichButton)
       {
              try
              {
               SharedPreferences.Editor editor = _State.edit();

editor.putBoolean(ConverterUtil.EVG_IS_SHOW_LICENSE_AGREEMENT, false);
               editor.commit();
              }
              catch (Exception e)
              {
         e.printStackTrace();
        }
       }
      });
      builder.setNegativeButton(R.string.lblButtonExit, new
DialogInterface.OnClickListener()
      {
       public void onClick(DialogInterface dialog, int whichButton)
       {
        finish();
       }
      });

      LayoutInflater inflater = LayoutInflater.from(this);
            builder.setTitle(R.string.lblLicenseCaption);
            builder.setIcon(R.drawable.my_converter_32);
      ScrollView layout = (ScrollView) inflater.inflate(R.layout.about,
null);

  
((TextView)layout.findViewById(R.id.txtAbout)).setText(R.string.lblLicenseText);

  
((TextView)layout.findViewById(R.id.txtMyEmail)).setVisibility(LinearLayout.GONE);
      builder.setView(layout);
      return builder.create();
     }

--



Other Threads

1. Paint & onTouch

Hi!
I have a problem with one of my app. I try to make a paint application
but nothing is draw on the screen (except the first circle which is
draw on the launch).
The log Cat seems to be correct and i get the right x/y coordinates. I
think i do something wrong on the ondraw.

do you see my problem?

Thanks.

this is my code :

public class Main extends Activity {
    /** Called when the activity is first created. */

        private TableLayout myView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i("onCreate", " Start");
        setContentView(R.layout.main);
        myView= (TableLayout)findViewById(R.id.TableLayout01);
        myView.addView(new PaintView(this));
    }
}

public class PaintView extends View implements OnTouchListener {

        private float _x, _y;
        private int _taille;
        private Canvas _myCanvas;
        private Paint _paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        public PaintView(Context context){
                super(context);
                Log.i("Info", "_paintview Constructor 1");
                //this.setFocusableInTouchMode(true);
                _x=20;
                _y=20;
                _taille = 10;
                _paint.setColor(Color.RED);
        }

        public PaintView(Context parent, float x, float y, int i) {
                super(parent);
                Log.i("Info", "_paintview Constructor");
                _x=x; _y=y; _taille = i;
                _paint.setColor(Color.RED);

        }

        @Override
        protected void onDraw(Canvas canvas) {
                Log.i("Info ","onDraw start");
                try{
                        // make the entire canvas white
                        canvas.drawColor(Color.WHITE);

                        canvas.drawCircle(_x, _y, _taille, _paint);
                        super.onDraw(canvas);

                        Log.i("Info ","x="+_x+" y="+_y);
                        _myCanvas=canvas;
                }
                catch(Exception e)
                {
                        Log.i("ERROR", "onDraw : " + e.getMessage());
                }
        }

        public void translate(float x, float y){
                try{
                        _x=x;
                        _y=y;
                        this.draw(_myCanvas);
                }
                catch (Exception e){
                        Log.i("ERROR", " "+e.getMessage());
                }
        }

        @Override
        public boolean onTouchEvent(MotionEvent evt){
                translate(evt.getX(), evt.getY());
                return true;
        }

        @Override
        public boolean onTouch(View v, MotionEvent evt) {
                translate(evt.getX(), evt.getY());
                return false;
        }
}

--~--~---------~--~----~------------~-------~--~----~

2. How to get the framework's coverage?

I'd like to get the coverage of framework part (under /path/to/mydroid/
frameworks).

Thanks to the topic "EMMA Code coverage and JUnit", I cound get the
coverage of the application part but couldn't get framework part yet.

What I tried are:

1. Build andoroid from source code with EMMA_INSTRUMENT=true and make
sdk.
    I get around browser build error with -no-local option.
2. Launch the emulator with the sdk's image.
3. Launch a test application with runtest.py commands with --coverage
option.

But all I could is only application part's coverage.

I suppose I have to run the framework package (android.jar) on the
instrument to get coverage but I have no idea.
Please let me know the way to do so. Any help is welcome.

--~--~---------~--~----~------------~-------~--~----~

3. how webview recoginze phone number

4. PendingIntent not firing at the requested time

5. Is is possible to handle voice packets in android?

6. Using ICU4J with Android

7. BrowserCallbackAdapter