Android : Way To Stop GPS Inside An Activity

Aug 12, 2010

Currently working on a simple app to allow users to find various things around them. When the activity that shows the Google map is active I can see the GPS icon on the status bar, which is normal. But I need to be able to stop the GPS hardware when my user navigates away from the activity, and switch the GPS back on when the activity is shown.

Is there a simple way to stop GPS when a user navigate away from an activity? I have tried the LocationManager's removeUpdates() but this doesn't actually stop the GPS (the icon is still flashing on the status bar and draining the battery).

What I'm looking for is a simple way to programatically stop the GPS hardware.

Android : Way to Stop GPS inside an activity


Android :: How To Get Activity View Inside That Activity?

Nov 11, 2010

I want to show my next activity withing my previous activity layout "LinearLyout". But it is not working. Can any one help? I put my last activity layout reference to a global class in an static variable. My code...

View 3 Replies View Related

Android :: Add Activity Indicator Inside An Alert?

Nov 24, 2010

Is it possible to add an activity indicator as a part of an alert. i need this bcos it is difficult to show alert view in white background.

View 1 Replies View Related

Android :: Display Widget Inside Activity?

Jun 2, 2010

I was wondering if there is a way to show a widget that I have created inside an activity. I have a weather widget and I also have an app I am working on that I would like to include weather reports in. Is there a way I can just re-use the widget code and make it show inside the weather activity?

View 4 Replies View Related

Android :: How To Embed External Activity Inside One Of Mine?

Nov 22, 2010

I need an Activity showing a specified PDF and two buttons. Is possible to embed an external PDF viewer - showing a specified URI - inside the view of my application? How can I do it?

View 5 Replies View Related

Android :: Put Camera Preview Inside A Surfaceview In An Activity Xml Gui

Aug 27, 2009

I just got my camera preview working for my app, but it is not appearing where I want it to appear, and I'm not sure how to get it there. Instead of using the entire screen for the preview, I would like to put it inside a surfaceview in an activity xml gui. What do I need to change? Here is my code:

public class TakePic extends Activity {

SurfaceView camSurface;

Preview camPreview;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);//hide window title

camPreview = new Preview(this); //create preview

setContentView(R.layout.takepic);

setContentView(camPreview); //set preview as activity content

camSurface = (SurfaceView) findViewById(R.id.camsurface); }

View 5 Replies View Related

Android :: Start An Activity Inside Any Layout In Droid?

Sep 24, 2010

I have created a an activity named Example which have 3 LinearLayouts . I want to start an activity. So I used the following lines of code...

Test is another activity. As a result of the above code a new activity is called in new page. But I want to get the same resule or start the activity inside 2nd layout of Example class.

How to achieve this.

View 1 Replies View Related

Android : Access A Method Of An Activity Inside TabActivity?

Oct 1, 2010

I would like to access the public method of an Activity run by a TabActivity using: Code...

Basically, what I what is to let the parent Activity call a method in child Activity in order to do something. Is this possible?

I did try this:((TeamHuddleScreenMsgsView)getTabHost().getCurrentTabView().getContext()).refreshModel(); but I'm encountering a ClassCastException. It seems that the getContext() still gives the TabActivity. Any help on how to get the child Activity?

View 2 Replies View Related

Android : Inside TabActivity / How To Get Instance Of Current Tab Activity?

Apr 23, 2010

I have attached a menu to my TabActivity, and when a menu item is selected, I would like to do something different based on which view is being currently displayed in the TabHost.

int getCurrentTab() returns me the id of the current tab... but from that int how can I get the instance of the activity running?

I also tried getCurrentView(), getCurrentTabView(), but these return things I can't seem to cast to the class of the current activity.

View 3 Replies View Related

Android :: Method Of Service Does Not Take Place Immediately From Inside Activity

Aug 6, 2010

I have an activity A which uses SharedPreferences to share data with a service S, which is called from within A.Now when I call the stopService() method from A, the onDestroy() method in S is not called immediately.I thought that all the activities and services under a single apk run in just one process. Why then does the jump to onDestroy() not take place immediately instead I can see the output from onDestroy() after the further code in the activity A is executed.

View 5 Replies View Related

Android :: Accessing Activity Methods Inside Click Listener

Aug 25, 2009

I have a click listener:
private OnClickListener onMyListener = new OnClickListener() {
public void onClick(View v) {
myMethod();
} };

And my Method:
private String myMethod() {
TextView tv = (TextView) findViewById(R.id.TextView1);
return (String) tv.getText();
}

When it calls this method, at tv.getText() it breaks in the debugger.
With this in the stack --
ViewRoot.handleMessage(Message) line: 1571
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3948
Method.invokeNative(Object, Object[],
Class, Class[], Class, int, boolean)
line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 782 ZygoteInit.main(String[]) line: 540 NativeStart.main(String[]) line: not available [native method]

View 2 Replies View Related

Android :: Cannot Call Method Of View Object Inside Activity

Nov 7, 2010

In my program I have a custom view object. Inside the view class is a method called foo. For some reason when I call foo from my activity, it doesn't fire. Here is the code:

XML of the custom view:
<com.company.application.MyView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" />

The activity code:
public class Main extends Activity { MyView mView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.main, null); mView= (MyView) v.findViewById(R.id.my_view);
//A button to fire the method inside foo() Button switchLeft = (Button) findViewById(R.id.switch_left); switchLeft.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { callTest(); } } );
} public void callTest() { Log.w(this.getClass().getName(), "clicked left arrow");
mView.foo(); mView.postInvalidate();
} }

Finally here is foo:
public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas); Log.w(this.getClass().getName(), "background set");
}

The first log is always written when the button is pressed, but the second log is not because foo never fires. What is the deal here? Upon request, the full view

public class MyView extends View { Drawable mBackground; Context mContext;
public MyView (Context context) { super(context); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public MyView (Context context, AttributeSet attrs) {
super(context, attrs); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas);
Log.w(this.getClass().getName(), "background set"); }
@Override public void onDraw(Canvas canvas) { Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL); // draw a solid blue circle
paint.setColor(Color.BLUE); canvas.drawCircle(20, 20, 15, paint);
// draw a test background mBackground.setBounds(0, 0, 300, 400);
mBackground.draw(canvas); }
}

View 1 Replies View Related

Android :: How To Use Multiple Views Inside A Single Activity With A Canvas?

Nov 7, 2010

Basically what I am trying to accomplish is I want a canvas I can pass bitmaps to, to be displayed on the screen with the rest of my view objects (buttons, textviews, etc).

View 1 Replies View Related

Android :: How To Show A Webview Inside An Activity In Middle Of Screen

Jul 30, 2010

I am having issue while showing a WebView in an activity in the middle of the screen. I have an activity and I want to show a webview in the center of screen. My activity is transparent so background activity will be visible. Whenever I try to create a webview and add it to activity using setContentView(webview) it always shows the view on the top left corner of the screen. Is their a way to workaround this?I am trying to do this via pure code only.

Here is my code.

CODE:....................

View 1 Replies View Related

Android :: Check Condition Inside OnCreate() Of Activity And Display An AlertDialog?

Aug 18, 2010

I am new to Android and this is my first question here so please go easy on me.

Is it possible to check some condition inside onCreate() of an Activity and display an AlertDialog?

I am creating an AlertDialog anonymously in Oncreate() and calling show on that instance but the AlertDialog is never displayed.

View 1 Replies View Related

Motorola Droid :: Media - Whenever Move Around Headphones Inside Jack Music Stops Or One Of Ear Buds Stop Working

Jan 11, 2010

Well the problems started 3 weeks ago when i noticed whenever i move around the headphones inside the jack, the music stops or one of the ear buds stop working. so i thought it was the headphones since skullcandies don't last long. i got a new pair and listened again but it STILL HAPPENED . (btw, the phone is not rooted)

The Phone still plays media fine without the headphones, so i thought no big deal. NEW PROBLEMS started to occur. The phone would NOT PLAY Media files whatsoever. (games, music, notifications, APPS ) every time it happens i have to restart the phone.

View 1 Replies View Related

Android :: ScrollView With Buttons Inside / No Response Until Second Click On Any Button Inside

Oct 30, 2010

I've been a couple of days trying to solve this thing but I can'f figure it out.The problem is, simple activity, with simple layout, ScrollView -> LinearLayout -> and a lot of buttons inside the layout (within the scroll content). Everything works just fine but one tricky thing. When I click a button let's say at the top of the scroll content and inmediatelly I scroll down to the bottom of the content and I click other button there, nothing happens until I click a second time and all come to normal again.This can be reproduced anytime and it's code independent (i've tried more than 20 scenarios). I've not much experience in android yet but looks like the scroll listener stops the onclick listener or something like that.

View 1 Replies View Related

Android :: How To Stop An Activity?

Feb 16, 2009

I have one Activity, that starts one Service and my service will lunch one Activity, i wanna to stop the Activity which one started my my Service after few seconds. Is there any way to achieve. Has anyone experienced this type of scenario.

View 5 Replies View Related

Android :: Stop An Activity

Mar 19, 2010

My application contains three-four pages.On click of button in first page,I start a new activity which redirects to another page and second page redirects to third page and so on.Now I want to include one button which On click will redirect to first page by stopping all activities. So how to achieve that?

View 5 Replies View Related

Android :: Stop Activity Animation?

Aug 3, 2010

I want dont want the activity animation that comes by default when we start a new activity (i.e. the right to left scrolling effect to new activity view) so i googled a bit and found a flag FLAG_ACTIVITY_NO_ANIMATION in the Intent class also i applied that flag to my intent via the setflags() method but somehow i still see the activity animation when a new actvity is launced ( i am developing in android 2.1 update).

View 6 Replies View Related

Android :: How Can I Stop A Thread In A Activity?

Dec 9, 2009

My problem is: Activity A called Activity B, and in Activity B, it start a background thread to do some client-server work. But it maybe takes too much time. So i add a cancel button to call the stop() method to stop the thread, and call finish() to finish the Activity B and go back to Activity A. Although it is back to Activity A, the thread isn't stop immediately. Can i just call the finish() to go back to Activity A, and leave the thread to exit by itself? If it is not the right way, which is?

View 10 Replies View Related

Android :: Unable To Stop Activity

Feb 10, 2009

I have an Activity which gives me the following stack trace error and it looks to be out of my control (I could be wrong though as I'm a newb to Android).Can anyone point me in the right direction? (It happened when I clicked on the back button)

View 2 Replies View Related

Android :: Stop Or Refresh An App Activity

Aug 12, 2010

I have a START and STOP button in the main screen of an App. there are some GUI and threads that are instantiated when I click on START. When I click on stop, I want everything to be stopped and the activity should come back to its origin state. To the state that is exactly same like when launched (when we tapped on App icon in mobile).Is it possible to do this? I tried with finish() , this killed the app and exited . I don't want to exit from main screen. rather, on clicking STOP I want app to come back to origin or born state.

View 2 Replies View Related

Android :: How To Stop Activity Destruction?

Dec 7, 2009

I would like to know if there is a way to stop activity destruction upon physical keyboard slide in/out event.

View 4 Replies View Related

Android :: How To Start Stop Activity?

Sep 21, 2010

1. press home key to stop my AP (activity change to stop , not destroy )

2. use "CountDownTimer" for sleep 3 secs , when timer finish use sendBroadcast() to call my BroadcastReceiver

3. finally , BroadcastReceiver use intent to start my AP (activity change to start).

View 3 Replies View Related

Android :: ListView Inside LinearLayout Inside ScrollView

Jul 7, 2009

So I've been extremely frustrated by this for a long time now.I've posted before, but can't seem to find a good solution. My goal is to have something pretty much exactly like the installed application details page in the Android Market.I need a list of items displayed along with other content above the list, and would like the content above to scroll up along with the list (exactly like the application details does for the "My Review" and other descriptive info).Due to responses to my previous posts, I came to believe that it really wasn't possible to do this with a ListView.So rather than using a ListView, I refactored my code to use a simple LinearLayout and add individual View items to the list, thinking I could just set each View as clickable and add an OnClickListener to each View in the LinearLayout.That's not working at all though, and now I'm getting even more frustrated.If someone can help me get the OnClickListener working, then I think it'll work, but I do need a separator for the LinearLayout.How do I add a separator like the one used for ListView to my LinearLayout?

View 12 Replies View Related

Android :: Stop Mediaplayer From Previous Activity

Feb 16, 2010

Can anyone tell me how to stop media player that was started in a previous activity?For ex. In activity-1 button pressed that did - mp.start(); then activity-2 starts for different layout with new buttons, then when button pressed, mp.stop is called, but does not stop the media from the first activity.

View 4 Replies View Related

Android :: AsyncTask Won't Stop Even When Activity Has Destroyed

Mar 27, 2010

I have an AsyncTask object which starts executing when the activity is created and does stuff in the background (downloads upto 100 images). Everything works fine but there is this peculiar behavior which i'm not able to understand.For eg: when the android screen's orientation changes then the activity is destroyed and created again. So I override the onRetainNonConfigurationInstance() method and save all the downloaded data executed in the AsyncTask. My purpose of doing this is to not have AsyncTask run each time activity is destroyed-created during orientation changes, but as i can see in my logs the previous AsynTask is still executing. (The data is saved correctly though)I even tried to cancel the AsynTask in the onDestroy() method of the activity but the logs still show AsynTask as running.This is really strange behavior and would really be thankful if someone can tell me the correct procedure to stop/cancel the AsynTask.

View 1 Replies View Related

Android :: What Is Best Way To Stop Activity And Alert User?

Sep 2, 2010

I have an application that must create a database and if that fails, then no sense moving forward. I've built an AlertDialog and show() it but it never displays. The logic falls through and then barfs because of the missing database.What is the right/best way to throw up a message and halt the activity? The code below executes fine (meaning the show() occurs while debugging and it falls to the next line) but the UI never displays this alert.BTW I realize the throw might not be the most graceful but I'm not even getting that far so.

View 2 Replies View Related

Android :: Stop Activity Appearing When An App Is Reopened?

Apr 17, 2010

In Android, I have some code to check whether the user has GPS switched on, and launch the Settings for them to turn it on if they don't.However, I'm finding that if the user opens the Settings, turns GPS on, then carries on using the app as normal, there is an odd problem. Often, when the user reopens the app, the Settings are at the front. How can I set them so they don't keep reappearing?I wonder if I should be using the CLEAR_TOP flag or something similar.I've tried looking at the docs for the Activity flags but find them a bit confusing.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved