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?

Android : Access a method of an Activity inside TabActivity?


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 :: 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 :: ListView Inside TabActivity?

Aug 21, 2009

I wanna put a "List" inside a TabActivity. by google and coder's guide, my work out "direction" is to create a "TabActivity" as MAIN and "ListActivity" then add it in the "TabHost" and turn out code something like (below) and fail:

CODE:.........

I know i may need to spend more time on the BOOK and google for android development, but i also feel that the resource for android is quit scattered and not detail. (i'm a developer of C# for a few years, and it's more easilier to search for information)

View 2 Replies View Related

Android :: Access Listview From TabActivity

Apr 20, 2010

I can't find the way to get ListView reference that is the part of TabActivity. I have 2 tabs - ListView, TextView. Theare no problem to access TextView using the following code in TabActivity:

CODE:........

But frame.getChildAt(0) returns com.android.internal.policy.impl.PhoneWindow$DecorView And I actualy don't know the way how to cast this reference to the object and to get its ListView child.

Tab initialization code:

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

View 2 Replies View Related

Android :: Restarting An Activity Within A Tab - TabActivity

Mar 13, 2010

I have a TabActivity, each tab holds an activity. At some point I'd like to 'refresh' the tabs. I'd basically like to restart each activity in the tabs. I'm not sure how to do this. Calling:

CODE:.........

Removes the tabs, but the activities still seem to be in alive, in limbo. How can I get them to really quit?

View 2 Replies View Related

Android :: Communication Between TabActivity And The Embedded Activity

Jun 28, 2010

I am trying to figure out the best practice of communication between a TabActivity and the child activity embedded in this TabActivity.

In my TabActivity, there is a button. When the button is clicked, I want the child activity embedded in this TabActivity to be updated. I wrote the code like below, and just wonder whether it is a good practice.

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

View 3 Replies View Related

Android :: TabActivity How To Show Contact Activity In A Tab

Dec 29, 2009

I am developing an application and as part of it I would like to show a tabactivity and use the contact activity to let the user see,modify,or call a specified contact.

My code is this:

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

View 3 Replies View Related

Android :: SetResult() For A TabActivity Which Contains Activity For Tabs?

Jul 30, 2010

My TabActivity contains two tabs which calls two two different activities . I want to setResult() for the TabActivity when either one of the child finishes.

Is there any method to find out when my activity inside tab finishes?

View 4 Replies View Related

Android : Restarting An Activity In A Single Tab In A TabActivity?

Mar 12, 2010

I have a TabActivity. Each tab points to a sub activity. Works great.

Is there any clever way to refresh one of the activity tabs? I just want to 'restart' the activity in tab #3 for example. Not sure of a good way to do this other than building in refresh support to the activity itself, or clearing ALL the tabs and recreating all of them.

View 1 Replies View Related

Android :: Add Tab Layout Without Letting Activity To Extend TabActivity?

Jul 21, 2010

I want to add tabs to the layout of my activity, but I don't want the activity to extend TabActivity. The example in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html only gave example of subclass of TabActivity.

Is there any way I can make it without extending TabActivity?

View 1 Replies View Related

Android :: Sending A String Created Inside A Method To Another Class

Sep 12, 2010

I have code which has one activity which passes information to a second activity.
I can use this information to pass to a third activity with additional information from the result of the second activity.

I want to use gestures as a method of going back to a previous activity, but if I go back from the third to the second activity I need the information initially passed from the first to the second activity to still be present.

i.e.

First Acticity

what is Y?

answer y = 5

Second activity

User said Y = 5

what is X?

Third Activity

User said Y = 5
X = 6

Go back to Second activity but maintain the input of

User said Y = 5.

To do this I have used a bundle to pass the information between activities, but I can only access the info in the bundle from within a method within the class started by the intent.

The gesture controls are within another class, so I cannot access the bundle information from within this class as the getIntent command produces a not defined error.

What I need to do is to be able to pass the information from the bundle from the first activity to the gesture class so that I can pass it back when I go back using the gestures.

View 1 Replies View Related

Android :: TabActivity Crash When Create Tabbed View In Widget Configure Activity

Dec 4, 2009

I'm trying to create a tabbed view in my widget configure activity. I'm using a tab activity as my activity type and I have the following code..................

View 2 Replies View Related

HTC EVO 4G :: Root Access - Unrevoked Method To Grant Superuser Access For Apps

Jun 23, 2010

I even tried flashing a custom rom (Fresh) on the last attempt and it just seems like it is giving me the Sprint stock Rom. Shouldn't the custom Rom look different? Once rooted do I still need to use Unrevoked method to grant superuser access for Apps?

View 9 Replies View Related

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 :: Inside Service Class / Executing Method For Toast From Scheduled TimerTask

Apr 30, 2010

I am trying to execute a {public void} method in Service, from scheduled TimerTask which is periodically executing.This TimerTask periodically checks a condition. If it's true, it calls method via {className}.{methodName};However, as Java requires, the method needs to be {pubic static} method, if I want to use {className} with {.dot}.The problem is this method is for notification using Toast(Android pop-up notification) and Status Bar.But for this to work, the method must not have {static} modifier and resides in Service class.So, basically, I want background Service to evaluate condition from scheduled TimerTask, and execute a method in Service class.Can anyone help me what's the right way to use Service, invoking a method when certain condition is satisfied while looping evaluation?

View 1 Replies View Related

Android :: Keep Images Inside JAR And Access Files?

Oct 26, 2010

I am creating an SDK .I have got some problems as follows:

i need to have some predefined images along with the jar.please suggest any method to do this thing. like 1) how to keep the files in jar and 2) how to use it in code.

If any code is very helpful or just any information is very helpful.

View 3 Replies View Related

Android :: Package And Access Extra Files Inside Apk

Mar 3, 2010

I have some data files that I need to install together with my application on the emulator for easy testing my app on a device.

Where can I put files in a way that Eclipse will include them into my apk and how can I access those files after my application is installed on the device?

View 1 Replies View Related

Android : Unable To Access R.id From Inside Custom View

Mar 3, 2010

In my foo_layout.xml file I have a subclassed RelativeLayout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.android.myapp.FooView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pegboard_table"
android:orientation="vertical"
android:scaleType="fitXY"
>
<ImageView
android:id="@+id/triangular"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/pegboard_board"
android:scaleType="fitXY"
android:gravity="center"
android:visibility="invisible"
/>
<Chronometer
android:id="@+id/timer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/timer_display"
android:textSize="40sp"
android:textColor="#000"
android:layout_alignParentTop="true"
android:gravity="center"
android:visibility="invisible"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/board_table"
android:visibility="invisible"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:background="@drawable/tab_bar">
<!-- android:layout_alignLeft="@id/options_tab"-->
<ImageView
android:id="@+id/game_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/game_select" android:paddingLeft="15sp"/>
<ImageView
android:id="@+id/undo_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/game_select"
android:layout_weight="1"
android:src="@drawable/undo"
/>
<ImageView
android:id="@+id/settings_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/undo_select"
android:layout_weight="1"
android:src="@drawable/settings"
/>
<ImageView
android:id="@+id/info_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/settings_select"
android:layout_weight="1"
android:src="@drawable/info"

This doesn't seem like the right behavior. I've tried it with other views inside the FooView hierarchy and findViewById() always returns null.

For the life of me I can't figure out what I'm doing wrong.

View 2 Replies View Related

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.

View 2 Replies View Related

Android :: Access Views Inside Layout When I Reuse It Multiple Times?

Aug 6, 2010

I have read the Android UI trick 2 on Android developers, which tells people how to include a layout in another layout file multiple times, and give these included layouts different id. However, the sample here is overwriting the layout id, not the id of the views IN this layout. For example, if the workspace_screen.xml looks like this: And I include it three times in another layout file. Do I end up with three TextViews with id firstText, and another three with secondText? Isn't there an id collision? And how do I find the secondText TextView in the third included layout with findViewById? What should I input in the findViewById method?

View 1 Replies View Related

Android :: Can't Access Private Members Inside An AlertDialog's OnClick Event / Fix It?

Oct 12, 2010

I'm very new on Android development.

I have this code...

But this line doesn't work:

extraData.putInt(Constants.GAME_ID, this.gameId);

I can't get access to this.gameId.

How can I fix this?

View 1 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 :: Want To Access Method From Different Application

Jun 15, 2010

I have two applications installed on my emulator, 1st application has 3 methods in it , If I want to call one of the methods from the second application , what should I do? I have tried to launch the activity its working fine. But now I don't want to launch the application rather use some functionality of the application with out launching it.

View 2 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 :: How To Access Preferences In Static Method

Aug 21, 2010

I have a broadcast receiver that needs to notify a service that it has received a text message. The only way to do this (as far as I know) is a static method. But the method that is notified need access to the application's preferences.

Every method I have tried says that it cannot be accessed from a static method. So how do I access preferences from a static method?

View 2 Replies View Related







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