Can u help me to find the mistake? i can't run this program.

by 鑿犺彍鍐 » Fri, 29 Oct 2010 19:18:53 GMT


Sponsored Links
 package com.android.CirclingCounter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class CirclingCounter extends Activity {
        private SensorManager mSensorManager01;
        private TextView displayTextView;
        int i=0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
                displayTextView=(TextView)findViewById(R.id.display);
                displayTextView.setText(i);
                
mSensorManager01=(SensorManager)getSystemService(Context.SEARCH_SERVICE);
    }

        private final SensorEventListener mSensorListener= new 
SensorEventListener()
        {
                @Override
                public void onAccuracyChanged(Sensor sensor,int accuracy)
                {
                        
                }
                @Override
                public void onSensorChanged(SensorEvent event)
                {
                        if(event.sensor.getType()==Sensor.TYPE_ORIENTATION)
                        {
                                float 
fPitchAngle=event.values[SensorManager.DATA_Y];
                                if(fPitchAngle<-120)
                                {
                                        i++;
                                        displayTextView.setText(i);
                                }
                                else
                                {
                                        
                                }
                        }
                }
        };
        @Override
        protected void onResume()
        {
                List<Sensor> 
sensors=mSensorManager01.getSensorList(Sensor.TYPE_ORIENTATION);
                mSensorManager01.registerListener(mSensorListener,
sensors.get(0),SensorManager.SENSOR_DELAY_NORMAL);
                super.onResume();
        }
        @Override
        protected void onPause()
        {
                mSensorManager01.unregisterListener(mSensorListener);
                super.onPause();
        }
}

--



Can u help me to find the mistake? i can't run this program.

by TreKing » Mon, 01 Nov 2010 00:59:36 GMT


 The mistake is you posted a bunch of code with no context and have not even
explained what problem it is you're having.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--


Sponsored Links


Can u help me to find the mistake? i can't run this program.

by davemac » Mon, 01 Nov 2010 09:39:17 GMT


 I'm going to guess that asking for the SEARCH_SERVICE and casting it
to a SensorManager is not going to go well for you. You're probably
getting a NoSuchMethodException, yes?

- dave
www.androidbook.com




--



Can u help me to find the mistake? i can't run this program.

by Bob Kerns » Mon, 01 Nov 2010 10:36:46 GMT


 o, assuming he doesn't get an error even earlier, I'm sure he gets a
ClassCastException on that line. That happens before it even checks
for the method. NoSuchMethodException is somewhat more esoteric

The advice he actually needs is beyond the scope of this group. But
I'll sum it up:

"Learn to use the debugger". Running it under the debugger, set up to
stop on RuntimeException and Error, would leave it stopped at the
problem line, with a ClassCastException on the stack, and thus neatly
answer your question for you, in far less time than it took to ask
this group. And that skill will pay off many times a day.

On Oct 31, 6:39pm, davemac <davemac...@gmail.com> wrote:

--



Other Threads

1. Waiting for Debugger on Release Version.

Hello,

The problem is that my app gets block on my Nexus One phone with a
dialog
Waiting for de{*filter*} to attach.  Force close. when I don't have the
usb cable connected to the phone and running the de{*filter*}.

I have the debug flag set to false in the androidmanifest.xml file.
But the app(os) still appears to be looking for
the de{*filter*}.

I also pulled DevTools from the 2.1 emulator and loaded it on the
phone but the Development settings tab
errors out on the phone and it causes a Force Close condition in the
devtools app.

Does any one have any advice on how to get the phone to stop looking
for the de{*filter*} for my app?

I can solve the problem by renaming the app and recompiling. But who
wants to change the app name
just to go to the release version.

Thanks for any help.

Is there a version of DevTools that will work on Android 2.1 on the
Nexus one phone.

--

2. EMMA code coverage

Hi,

I read various lists and blogs regarding setting up EMMA to obtain
code coverage. I am TA-ing a software engineering class and it would
great to have the students measure code coverage. Unfortunately, it
seems EMMA is still in early development and there are still a few
problems setting it up.

I have a few questions:

Is there any alternative to EMMA?

Getting EMMA to work requires recompiling the SDK. Is it still the
case in 1.6?

The problem is that most of the students in the course will use
Windows and compiling Android on Windows is not supported.
If there is an easier way to get an EMMA enabled image, I would be
grateful if someone can post an updated tutorial for 1.6.

Alternatively, would it be possible to also link an EMMA enabled SDK
to the Android download page for Linux, Mac OS X and Windows?

Thanks,

Cristi

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

3. how to load XML files dynamically

4. Basic Emma code coverage tutorial needed

5. ContentProvider's DB file access right problem when its android:multiprocess=true

6. removing item from ListView

7. OOT | vynil itu apa ya?