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.

Android :: Sending a String created inside a method to another class


Android :: Created A Method In Another Class But I Can't Use It In OnClick Method From Main Class

Nov 1, 2010

I created a method called insertTable in a class called Table but i can't use it in my onClick method in the main class :

CODE:.......

I want to do a income.insertTable in the onClick method but eclipse say that i need to create a local variable.

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 :: Java Unable To Find Class At Runtime From JAR I Created

Nov 19, 2010

I am working through a facebook-sdk example and trying to utilize the collection of classes as provided as a .JAR. I am relatively new to java and eclipse so I expect I am making some obvious blunder.

The issue is that everything seems to compile fine, but when I run the project (using the android emulator) dalvik vm is unable to find the first class I reference from this facebook sdk. ( com/facebook/android/Facebook.class )

As an aside, if I copy the source directly into my project as an additional package everything works fine.

Step 1: I exported the com_facebook_android project as a .JAR file. ( right click project, export, java / jar file ) I choose c:datajagjar as my location to save facebooksdk.jar.

Step 2: I hit properties on the project HelloGoogleMaps, Selected Java Build Path, Libraries, Add External JARS... I the directly selected the c:datajagjarfacebooksdk.jar file.

At this point my project seems to be building just fine ( no errors ).

Step 3: Debug the project and receive the error:

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

View 3 Replies View Related

Android : OpenGL App - Created Rendering Class Which Implements GLSurfaceView.Renderer

Jul 16, 2009

I've created a simple OpenGL app and created a rendering class which implements GLSurfaceView.Renderer. All it does is draw 100 triangles (NUM_OBJECTS = 100) on the screen and move them about, bouncing off the edges. The projection is glOrtho2D and there is no z-buffer. I'm running this on a G1 with continuous redraw enabled.

Here is the onDrawFrame method:

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

View 23 Replies View Related

Android :: Display Game Created View Class - Error Thrown Line 26

Oct 7, 2010

When using this class I get this strange exception. It is used to print out a nice timer display for my game, and is created when my main GameView class is created. The error gets thrown at line 26: super(s*1000,1000);

package tommedley.android.game;

import android.content.Context;
import android.graphics.Canvas;...
public static int MODE_COUNTING = 0;
public static int MODE_PAUSED = 1;
public static int MODE_FINISHED = 2;...

View 49 Replies View Related

Android :: Embed A Class Inside Textview Of Another Xml?

Nov 19, 2010

This is my layout...

This xml is the main.xml with main.java. How can i embed intro.xml with intro.java into the <Textview>?

View 1 Replies View Related

Android :: Set An Intent's Class From A String Value?

Jun 10, 2010

I am trying to set the class for an intent to the address listed in a string value, so that I can launch a given activity. The string is composed dynamically during runtime.

Is there anyway to make something like the code below run...

View 2 Replies View Related

Android : Use Of A String Not An Array On Another Method

May 11, 2010

Im trying to make an activity that has a multiple choice dialog after you push a button. In there you select from a list of things. But these things are received from a web method before the dialog appears. So I create a string array after I receive them inside the onCreate to initialise it there with the correct size. But my dialog method then cant get the array because propably its out of its scope.

My code looks like this:

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

I cant initialise my array when the class starts because I dont know its size yet. This has to do something with the scopes of my variables and I am pretty confused

View 3 Replies View Related

Android :: Loading Layout From XML Inside Of Derived Class

Mar 4, 2010

Right now I have a class that extends LinearLayout and builds the view inside of the constructor using a series of addViews. I wanted to move this into an XML file, so I have the same view defined there. My problem is that I can't figure out how to load the XML file in the constructor of the derived class. I looked up the LayoutInflater stuff, but I wasn't entirely sure how to use it in that context. Do I need to call addView() with the result of the LayoutInflater? Is this even possible? The other issue is that the context object that is passed in doesn't have the LayoutInflater methods. I'm not sure if I need an instance of Activity to do that.

View 3 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 :: GetString(R.string In Static Method

Sep 29, 2010

When programming for Android sometimes you have to use static methods. But when you try to acces you resources in a static method with getString(R.string.text) you'll get an error. Making it static doesn't works. Does anyone knows a good way around this because the resource files in Android are very helpfull for creating things in different languages or making changes to a text.

View 2 Replies View Related

Android :: Method GetSharedPreferences - String - Int - Is Undefined?

Sep 24, 2010

I have the following code but there is an error: "The method getSharedPreferences(String, int) is undefined for the type EventsData".

Does it mean I need to extend both SQLLiteOpenHelper and Activity?
CODE:.............

View 2 Replies View Related

Android :: Sending String Over Bluetooth

Jul 27, 2010

I am trying to establish a server (J2SE) and client (Android). The client will send a string over to the server over Bluetooth. For Android the code snippet is as below: BluetoothAdapter adapter = null; adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(address); //I have hardcode the server bluetooth mac address adpter.enable();.............

View 5 Replies View Related

Android :: Check For Internet Connection Inside An Anonymous Class?

Dec 30, 2009

I was trying to make an anonymous class to upload a file to a server.

I wanted to make that easily reusable much like some kind of component.

Everything works fine but as a final touch i wanted to add a function to check if internet connection is available.

Problem is, the call to the connectivity manager needs the Context :

ConnectivityManager connec = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);

Since i'm in an anonymous class and I've read that it's not a good idea to pass the whole context to classes, I wondered about two things :

1 - Is there another way to check internet connection without the Context ? 2 - Why in Android internals make it necessary to have the context just to check if the device is connected to internet ?

View 6 Replies View Related

Android :: Add TextView Programmatically Inside A View-based Class?

Jan 11, 2010

I have been trying to find a solution for this for the last 3 days but i just failed hit a final answer!

I am creating a View-based class where i show a ball bouncing of the sides. I use a Timer to control the animation.

I want to add a TextView programmatically in my view class. I am trying to instantiate an object of TextView with reference to the context as follows code...

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 :: Store Second Value Beside Each String Without Implementing New Adapter Class?

Oct 14, 2010

I want to create a ArrayAdapter for one spinner. So each element contain one string (which will be displayed in the spinner/list) and one value (e.g. an ID). How I can easily store a second value beside each string without implementing a new Adapter class?

View 2 Replies View Related

Android :: Method OpenOrCreateDatabase - String - Int - Null - Is Undefined

Aug 15, 2010

I'm trying to open database as follows :

CODE:...

This code works fine when I implement it in the Service class, but when I try to implement this in the onPostExecute eventhandler of the GeneraterThread class,implementing AsyncTask, I get the following error :

'The method openOrCreateDatabase(String, int, null) is undefined for the type GeneraterThread'

View 2 Replies View Related

Sending Text String Using WiFi From ICS Android?

Jun 18, 2012

I want to develop a simple app which send a small string like "arun" to other device which can receive data using wifi..

View 7 Replies View Related

Android :: ViewFlipper Not Working Inside A Class Which Extends LinearLayout / Reason Of It?

Apr 22, 2010

When I tried to create a ViewFlipper inside a class which extends LinearLayout, its throwing an exception

"java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()".

I am creating the ViewFlipper using,

ViewFlipper flipper = new ViewFlipper(ctContext);

But when I create the ViewFlipper in a class which extends Activity, its working normally. What may the reason?

View 3 Replies View Related

Android :: Loading String Values From File Instead Of List In Class

Nov 1, 2010

I think I have a pretty easy problem to solve, but I have been beating my head against the wall for hours trying to get past it! I have an adapter that loads a list of URLS:
adapter=new MyAdapter(this, lStrings);
list.setAdapter(adapter);

The list of URLS looks like this:
private String[] lStrings={
"http://www.domain.com/file1.jpg",
"http://www.domain.com/file2.jpg",
"http://www.domain.com/file3.jpg",
};

What I want instead is to load these values from a text file that lies on the SD card. For that matter, I would be okay with loading the values from a text file into a String, and then load the String into the list as I imagine that would be the "cleaner approach". However, all attempts to do this have failed. For instance, I replaced the above snippet with this:

private String[] lStrings=
{ MainActivity.this.getString(R.string.myurllist) };
but then I get a Forced Close on loading.

I'm a bit new to Java, Android, and development in general.

View 1 Replies View Related

Android :: Class That Turns That An XML String Into Java Object - ClassNotFoundException

Jun 22, 2010

So I ran into a problem today while working on my Android program. I have a class that turns that an XML string into a Java object (third party) and it works fine in as a regular java project but on Android I get this weird error:

CODE:.......

I hide my application name and my package for obvious reasons but I was wondering if anyone has ever encountered problems like this. Class is in the correct package, which is a library I have added. Other classes that I reference before are there and those can be made. Are there any other reasons a ClassNotFound Exception is thrown?

View 2 Replies View Related

Android :: Access To String 'Icon List' Given IconListActivity.class?

Sep 22, 2009

Code...

How do I access to the string 'Icon List' given IconListActivity.class?

View 1 Replies View Related

Android :: Resolution - Method GetText() Undefined For Type String

Apr 23, 2009

I'm a new android developper and I have problem with my database. In fact, I have done: private EditText name; private EditText number; private void saveState() {String name = name.getText().toString(); String number = number.getText().toString(); I have this message:" The method getText() is undefined for the type String"

View 2 Replies View Related

Android :: Way To Call Another Class Method?

Aug 28, 2009

You need a reference to the class that contains the method you want to call. To access the method homepage() inside the eSkyGuide from the class Weather, you need an instance of the eSkyGuide class inside the instance of the Weather class.

View 4 Replies View Related

Android :: Sending Data To HTTP Servlet And Receiving String

Dec 30, 2009

This is the servlet code in java ME.

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
ArrayList<String> listName = new ArrayList<String>();
ArrayList<Integer> listLongitude = new ArrayList<Integer>();
ArrayList<Integer> listLatitude = new ArrayList<Integer>();
String sLongitude = (String) request.getParameter("x");
String sLatitude = (String) request.getParameter("y");
String path, list, scount; Integer numLong = null;
Integer numLati = null; Connection con = null; String slanje = "";
int limitLeft, limitRight, limitUp, limitDown, icount = 0;
if (sLongitude != null && sLatitude != null) {
try { numLong = Integer.valueOf(sLongitude);
numLati = Integer.valueOf(sLatitude); } catch(Exception ex) {}
} try{ Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/bazaprojekt", "projekt2009", "midlet"); limitLeft = numLong - 8; limitRight = numLong + 8; limitUp = numLati + 8; ...

How do I send x and y to servlet and receive some string in Android?

View 2 Replies View Related

Android :: How To Get Method Of Listactivity From Activity Class?

Apr 19, 2009

Can i call method of Listactivity from Activity class? I have creates Intent object of myListActivity class and called startIntent() from myActivity class.

View 3 Replies View Related

Android :: Way To Call A Method Of Class Kept Under Other Package?

Oct 5, 2010

I am a beginner in Android Developing. Can any1 please guide me how to call a Method of a class kept under other package. Like class A in Package 1 calls a method in Class B of Package 2 which returns An array or object. Do i have to create an Intent for that? actually i have to gather all information in 1 class from different classes kept under different packages.

View 2 Replies View Related







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