开发者

Android: using network service

I m using network service so when i click on button in my first activity , if it is dependent on network then on its click if the network is not available then its should give message that network not available and if network is available it should able to redirect to my application.

So here i m sharing what problem i have

1> if network is available then i m calling intent from my main activity's button click event

mapbutton.setOnClickListener(new OnClickListener(){ @Override 开发者_运维百科 public void onClick(View v) { // TODO Auto-generated method stub ConnectivityManager connec = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

            if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || 
                    connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING ) {
            Toast.makeText(main.this,"You are:" + NetworkInfo.State.CONNECTED, Toast.LENGTH_SHORT).show();
            //Do something in here when we are connected
            // call intent to go to map
            Intent intent = new Intent(main.this,HelloMap.class);
            startActivity(intent);

}}

And in Else Condition i m displaying dialog that network connection unavailble...

HelloMap is my class which implements Map Functionality.

When i run my application it is giving error ... classdefnotfound HelloMap.java.

Can anybody tell me how to solve this proble

i have include permission ACCESS_NETWORK_STATE, include HelloMap class in manifest too..

Then also i m not getting proper output..

Can anybody help me.

Thanks Rakesh

            } 


When i run my application it is giving error ... classdefnotfound HelloMap.java.

Most likely, you are running on a device or emulator that does not have the Google APIs, and so does not have the MapActivity base class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜