Android :: How To Access Intent Value In Another Class?

May 5, 2010

I had write two classes IntentA and IntentB in my application (Both are in same package and both extends Activity class). In IntentA class I had created one button on pressing that button controll is trsnfer to IntentB class. IntentB class also contain Button on pressing that control is transfer to IntentA class.

This work fines. Now I want to set value in IntentA class using putExtra method and access that value in IntentB class How should I do that? I had put value in class IntentA like

Intent i1 = new Intent(this,IntentB.class);
i1.putExtra("Intent Name", "IntentA");
startActivity(i1);

Now I don't know How to access "Intent Name" value in IntentB class.

Android :: How to Access Intent Value in another Class?


Android :: Access Application Class From Class Other Then Activity

Sep 8, 2010

I'm new to Java and android development. In my application I need data which is accessible for a few activities. I've read that a good solution is to use Application class for this. So I use it like this:

public class MyApplication extends Application {
private String str;
public String getStr(){
return str;
}
public void setStr(String s){
str = s;
}
}

and I can access this variable from activity like this:........................................

View 2 Replies View Related

Android :: Passing Intent Value To Another Class

Oct 14, 2010

I have four groups in a listview each with four url's I want to load in a webView. When the user select a url to goto I set a value like so;

if (position == 0) webb = webb +2;
{
Intent intent = new Intent(this, official.class);
startActivity(intent);
}

I then carryout the intent to move to the webView class where I have given each URL a value like so;

if (webb == 2) mWebView.loadUrl("http://yahoo.com");
if (webb == 3) mWebView.loadUrl("http://www.bbc.co.uk");

But the screen stays blank, if I state the value inside the official.class it works. How can I get this value to pass to another class based on the selection the user makes from the listview.

View 3 Replies View Related

Android :: Passing Intent Value From One Class To Another

Oct 16, 2010

I have been trying to get "getExtra" to work but without success, I have a listview with 4 choices which launch a webpage within a webView class, when the user selects the option lets say option 3 I want to pass the value of 3 to the webView class so that it will load the correct webpage, at the moment I get no errors, but the app force closes when I select the option, could this be due to having to announce this in the manifest? can somebody help with where I am going wrong. This is my intent

public void onListItemClick(ListView l, View v, int position, long id) {
if (position == 0) {
Intent intent = new Intent(this, official.class);
intent.putExtra("weburl", 3);
startActivity(intent);}
This is the official class:
public class official extends Activity {
int number = getIntent().getIntExtra("weburl", 0);
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
} return super.onKeyDown(keyCode, event);
} WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browser1);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
if (number == 2) mWebView.loadUrl("http://bcafc.livewwware.co.uk");
if (number == 3) mWebView.loadUrl("http://www.bbc.co.uk");
mWebView.setWebViewClient(new HelloWebViewClient());

View 1 Replies View Related

Android : Way To Use Intent From Non-activity Class?

Jan 2, 2010

I have three classes one main-activity(named MainMap), one non-activity class(named MyItemizedOverlay), and one activity class(named AudioStream). I want to start AudioStream activity from non-activity class but i don't know how to.

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 :: Launching Intent From Class Outside An Activity

Jul 28, 2010

I've got two activities, one of them is called MyActivity. I want both of them to be able to use a function located in a class othat we may call MyClass. In MyClass, I try to use an intent to launch the activity AnotherActivity. Since the constructor takes a context as parameter, I simply tried to store a context from the activity in the constructor, and then use it when I try to create my intent.However, even thought none of the arguments are null (checked that with a simple if-statement), intent seems to be null and a NullPointerException is thrown. Why does it not work, and what can I do to solve the problem?
I'm quite new to Android and Java development, so please explain it as basic as you can.

View 2 Replies View Related

Android :: Transport Own Class With Intent Between Objects/

Jul 20, 2010

I'm programming an android application using the StartActivityForResult() - Method.
But, i want to get as result an own class, not a string or something like that.
how can i tell the intent to use the class i wrote to give back?

View 2 Replies View Related

Android : Droid Calling Intent From Another Class?

Jun 29, 2010

I am calling intents alot in my program and I thought that I could write a public class that would have all of my intents so I can just call something like intents.testIntent(params) and then have it fire off the intent.

I tried it out but am getting a force close with a null pointer exception. This is my whole class. I know it is probably sloppy but I have just been learning java for 2 months so I still am an amateur. Any way, my code...

View 1 Replies View Related

Android : Pssible To Have Extending Intent Class?

Jul 28, 2009

I was experimenting with extending the Intent class but don't seem to make it work properly. I am wondering if extending is even possible. Here is the snippets.

Code for custom intent: Code...

View 3 Replies View Related

Android :: Can We Pass Singleton Class's Object Via Intent?

Sep 3, 2010

Can I pass a singleton class's object from one activity to another activity using intent? I am using singleton class as image class img = image class.get Instance();, so i need the img instance for another activity, how can i pass an object instance in Android.

View 2 Replies View Related

Android :: Way To Identify Phone Intent Type From Another Class?

Aug 18, 2010

I create an Intent in one class then it's returned to another class. I need to check the type of intent it is. I need to ensure it's not a specific class of intent.

View 1 Replies View Related

Android :: Class Derived From Intent Service Must Have Default Constructor

May 8, 2009

I'm posting this to share the lessons I learned while working with IntentService. IntentService has a single constructor that takes a string argument "name". The documentation has no description of what name is used for. In looking at the sources, I found that its only use is in naming the worker thread for the IntentService. This thread is named IntentService [name].

I initially implemented the constructor of the derived class to also take a String argument and passed it along to the derived class. This is wrong. This will cause the startService() call to generated a java.lang.InstantiationException in the application containing the service i.e. you don't get the exception in the application calling startService(). A clue to the actual problem is a little further up in the logs:"newInstance failed: no <init>()"

The derived class must have a Default constructor and that constructor must call super() passing a string for the name component of the worker thread name.
public class MyIntentService extends IntentService {
public MyIntentService() { super("MyIntentService");
} @Override
protected void onHandleIntent(Intent intent) {
// Handle events on worker thread here }

View 2 Replies View Related

Android :: Intent - Receive Myval Data In Screen2 Class?

Feb 24, 2009

I have two classes Screen1 and Screen2 both extends activity i have to pass data from the Screen1 to Screen 2

I wrote in onCreate method of Screen1 class

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

My doubt is ,how to receive myval data in Screen2 class ,what is the code i have to add in AndroidManifest.xml file

View 6 Replies View Related

Android :: What Is The Significance Of Context In Various Constructor Of Intent Class When Starting An Activity

Mar 4, 2010

I had come across a code snippet which calls for an activity without referring to any context. Before, i was considering that context is used to tell about the calling component. But as i came see that another component can be called without any reference to context, it makes me wonder what purpose it might be serving. please put some light on it.

Here is the code which calls for an activity without referring to 'context'

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

View 1 Replies View Related

Android : Launch Browser Intent With Custom Class - Cannot Find Activity

Jul 25, 2010

I want to specifically run the default Android browser for a given URL. I'm using this code: I also tried adding <uses-library android:name="com.google.android.browser" /> to the manifest. Am I missing something here? PS: I'm not interested in using startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))) as it will list all the choices for the browsing Intent.

View 3 Replies View Related

Android :: Access To Class Not Allowed / What To Do?

Feb 6, 2009

I get an apk file from somewhere. I tried to install it the emulator successfully. (The emulator is built from the latest code in AOSP which should be cupcake or later). But I can't launch the application from the GUI. It complains "The application xxx has stopped unexpectedly." After checking the logcat, I find the message "access to class not allowed". It seems that that process is not allowed to instantiate the Activity class.

Since I can install the apk successfully, I am curious why I can't launch it as a user.

BTW, I tried two ways to install the app. 1) by copying it to /system/ app and rebuild the system.img 2) by using "adb install". Both getting the same error message.

I tried to extract the AndroidManifest.xml file from the apk. But it seems that the file is scrambled and can't read.

View 5 Replies View Related

Android :: Where To Put Custom Data And Access Them Via R-class Then?

Aug 5, 2010

In a typical Android project you have the res/drawable directories where you can put images but i have some special custom binary files.

where do I usually put them and can i access them via the R-class then?

View 2 Replies View Related

Android : Access Context Of A Class Which Is Not An Activity?

Jan 28, 2009

Can anyone tell me how to access context of a class which is not an activity?

View 10 Replies View Related

Android :: Core Class Access Resources At The App Layer

Sep 22, 2009

Can a core class such as "AbsListView" access resources, such as xml files, and .png's, in a 3rd party app installed in the normal way (at the app level)?

I realize this is a change in framework code, and that is fine for my purposes. So, for example, if I know that I am going to install an app called "MyApp", could I go into frameworks/base/core/java/android/ widget/AbsListView.java and tell it to use an xml file and .png's that live in that app? Here is the line I would want to modify: setSelector(getResources().getDrawable( com.android.internal.R.drawable.list_selector_background));

View 7 Replies View Related

Android :: Access Drawable Resources From A Not Context Class?

Nov 7, 2010

So I'm defining a class that sets a Drawable attribute in an object. The problem is that I can't access the getResource().getDrawable(int resourceId) method unless I have some Context.
So what I did was to send to that class an activity instance (let's call it "act") and then I did:

act.getResources().getDrawable(R.drawable.whellchair)

but, when executing that line it throws a NullPointerException.

When idea how to accomplish this?

View 2 Replies View Related

Android :: Android - Start New Intent But No Parent Class

Jun 28, 2010

I've a ListActivity with a ListView, onItemClick I start an Intent. Oncreate of this Intent I make a getParent but it's null. if I do this.isChild() it's false.
mPostList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent IntentDiscution = new Intent(parent.getContext(), EcrireMessage.class);
....
IntentDiscution.putExtras(objetbunble);
parentClass.startActivity(IntentDiscution);
}

View 3 Replies View Related

Android :: Way To Access Content Resolver Methodsn From AppWidgetProvider Class?

Dec 31, 2009

Is it possible to access the content resolver methods in a class extending from AppWidgetProvider class? Have been trying to do it with no luck so far.

View 3 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 :: Read Mail Intent With Access To Email Data?

Nov 17, 2010

Android documents starting the email intent for sending emails with Intent.ACTION_SEND. Is there an intent which directs the user to reading his email, or which launches the default email application? The application that launches the "read mail" intent would get no access to the email data.

View 1 Replies View Related

Android :: Creating A New Class Using Eclipse New Java Class Dialog Box

Jul 7, 2010

I'm creating a new class, using eclipse "New Java Class" dialog box. I can write the superclass I want (I can't find using "browse" button), but I can't write or select an interface to implement. I click "add" but ther is nothing to select. What I'm doing wrong?

View 4 Replies View Related

Android :: Communicating Between Receiver Class And An Activity Class

Jul 14, 2010

I'm just getting into Android development, and I have a question about communicating between a receiver class and an activity class. I'm very new to JAVA and Android so I hope I don't sound too stupid. I'm developing an application where I intercept an SMS message and then based on various elements of that SMS I might delete it once it's been saved to the inbox. I have a receiver class that intercepts the txt message, and I am also able to delete messages from my inbox with code in the activity class using a button at the moment. The problem I have is communicating between the receiver class and the activity class where the code to delete a message resides. I tried putting that code directly into the receiver class but as I'm sure most of you already know the BroadcastReceiver class doesn't seem to support what I need to delete messages. I've been searching for an answer to this for a while, but haven't been able to find anything. Honestly I'm not sure I know enough about JAVA and Android to even recognize a solution if I saw it.

View 2 Replies View Related

Android :: Accessing Class Level Stuff From Inner Class

Jun 27, 2010

What I want to do, is be able to access the object neoApi inside the Neoseeker class, from its inner class RunningTimer. Now, in my code, you can see what I would think to work, but when I run my application, nothing pops up. Nothing inside my TextView, no Toast, nothing at all. How can I remedy this?

package com.neoseeker.android.app;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONObject;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;.......................

View 1 Replies View Related

Android :: Call Activity Class From Other Java Class?

Oct 8, 2010

I have just started android. I just want to know that how can i call activity class from other java class. i just want to pass class object to activity class.

public class GsonParser extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MagazineThread thread=new MagazineThread();
thread.start();
}
public GsonParser(JsonMagazineParser Obj)
{

}
}

and i am just doing like from other class. GsonParser obj=new GsonParser(this);passing obj to activity class.how can i achieve that.

View 1 Replies View Related

Android :: How To Run Class In Background Among Package Of Class?

Apr 23, 2010

In my app in one package there are some classes. from those classes i want to run one class that is the Gps functionality class. i want to run that class in background. how i do it, i don't know. i am not able to make it solve from any document. if anybody knows the way to solve it please me by run a "hello world" app in the background. i am not able to solve this problem by going through document.

View 2 Replies View Related







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