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...

Android :: Set an intent's class from a string value?


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 :: Serializable Object In Intent Returning As String

Jun 16, 2010

In my application, I am trying to pass a serializable object through an intent to another activity. The intent is not entirely created by me, it is created and passed through a search suggestion.

In the content provider for the search suggestion, the object is created and placed in the SUGGEST_COLUMN_INTENT_EXTRA_DATA column of the MatrixCursor. However, when in the receiving activity I call getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY), the returned object is of type String and I cannot cast it into the original object class.

I tried making a parcelable wrapper for my object that calls out.writeSerializable(...) and use that instead but the same thing happened.

The string that is returned is like a generic Object toString(), i.e. com.foo.yak.MyAwesomeClass@4350058, so I'm assuming that toString() is being called somewhere where I have no control.

Some of my code

CODE:.........

This is in the activity that receives the search suggestion:

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

View 1 Replies View Related

Android : How To Create Intent Using A String To Launch Another Activity?

Mar 5, 2010

The first activity in my app needs to load a small amount of data from a text file. Two strings and an integer. Once I load the data, I want to use one of the strings to create an intent, that will launch the next activity.

View 2 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 :: 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 :: 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 :: Setting Intent Extra Value That's An Array Of String And Integer

Aug 3, 2010

I have a program that sends a broadcast Intent that needs an "extra" value.The value is declared as being of type Object[], though I know that the elements are always of type Integer or String.That's part of an API not under my control. What's the most concise and/or efficient way to do the equivalent of the putExtra call below?

View 6 Replies View Related

Android :: Service Intent Filter Action String Resource

Sep 13, 2010

I have a Service defined in the manifest with an intent filter that refuses to match when specified as a String resource but works when the literal action is entered in the manifest. Is there any reason I should not be able to use a String resource with an action in an intent filter?

View 3 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 :: 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.

View 5 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 :: 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 :: 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 :: Any Tools To Convert Iphone Localized String File To String

Jun 29, 2010

I have the localized strings file that is used in the Iphone app that I work on to port to Android. Are there any tools that go through the file taken from the xcode project and build the xml needed to use the strings in android? This tool should be easy to build but I appreciate any pointers to already working tools.

View 4 Replies View Related

Android :: Java Datetime Values From String To Long To String

Oct 1, 2010

In Android, capturing date from datepicker and storing as string in sqlite. Sorting by date doesn't work because they're strings (unless I'm doing it wrong.I've googled this issue for ~5 days, and it looks like there should be a way to capture the date from the date picker, convert it to a Long, store it in sqlite as a Long, select and sort on the Long date value, then convert the Long back to a "mm/dd/yyyy" string for display. I've tried various combinations of parse statements, Date, FormatDate, etc. with no luck at all.On activity start, get today's date and display it in button which calls the datepicker.Capture new date from datepicker (if one is entered), save it as a long to sqlite.On opening an activity showing a listview of records, select from sqlite with orderby on date (Long), convert Long to "mm/dd/yyyy" string for display in ListView.

View 3 Replies View Related

Android :: Access The String Values Of String Resources Statically

May 5, 2009

If there's anyway way I to access the String values of String resources statically? e.g. a static equivalent of Context.getString(...)?

View 5 Replies View Related

Android :: Reference String In String Array Resource With Xml

Nov 12, 2010

I have preferences where you can enable/disable what items will show up on the menu. There are 17 items. I made a string array in values/arrays.xml with titles for each of these 17 items.

I have preferences.xml which has the layout for my preferences file, and I would like to reference a single item from the string array to use as the title.

In the Android developer reference, I see how I can reference a single string with XML, but now how I can reference a string from an array resource in XML.

View 3 Replies View Related

Android :: How To Convert Binary String Data Into String?

Aug 4, 2010

Can anybody give me some clue that how to convert binary string into a string(english). I have tried and googled so much but couldn't find an answer.

View 1 Replies View Related







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