list of request codes - their names and values?

by for android » Thu, 09 Apr 2009 13:43:10 GMT


Sponsored Links
 The requestCode is the constant you send from ur code which starts the
activity

startActivityForResult(intent,100);


So you are sending the code 100.

you need to look at the result code which are RESULT_OK,RESULT_CANCELED
which are defined in the Activity class.





--~--~---------~--~----~------------~-------~--~----~



list of request codes - their names and values?

by Rob Franz » Fri, 10 Apr 2009 06:55:03 GMT


 But this is a RingtonePreference - I'm not starting the activity from code.
 RingtonePreference is defined in preferences.xml (which defines how the
Preferences are laid out).
All I know is that the request code - not the *result code* - that is
returned is 100.

I need to know the name associated with that value 100... I can't find it
anywhere :-)

Thanks
Rob






--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


list of request codes - their names and values?

by Mark Murphy » Fri, 10 Apr 2009 07:15:47 GMT


 


What are you attempting to achieve by listening on onActivityResult()
from a PreferenceActivity?

Is it something that could be handled better via a
Preference.OnPreferenceChangeListener?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



list of request codes - their names and values?

by Rob Franz » Fri, 10 Apr 2009 08:07:33 GMT


 What I am doing is getting the URI of the ringtone that the user selects in
the ringtone picker.  Then I save it for later use.
It works, but I'm just trying to figure out what that request code is.

Thanks
Rob






--~--~---------~--~----~------------~-------~--~----~



list of request codes - their names and values?

by Mark Murphy » Fri, 10 Apr 2009 08:19:47 GMT


 


That should be in your preferences, though. After all, you're the one
asking for the ringtone via the RingtonePreference, right?

Just open up your SharedPreferences
(PreferenceManager.getDefaultSharedPreferences()) and read out the
value. Or use Preference.OnPreferenceChangeListener to be notified when
the user changed your preference of interest.

I feel like I'm missing something...

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. GridView in a ListView: results are unusable the way it is now

> Here's a simple program that puts a bunch of GridViews inside a

Putting scrollable items inside scrollable items usually does not work
well in Android. I would recommend you use either a GridView or a
ListView.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html


-- 

2. GridView in a ListView: results are unusable the way it is now

Here's a simple program that puts a bunch of GridViews inside a
ListView. My original question was about how the list item that has no
GridView entries, or one row of entries, still has two rows. But, upon
further examination of the included program, the worse problem is that
the GridView items that have 3 rows are cut off. The ListView is not
giving enough space to include the entire height of the taller
GridView.

Sometimes the GridViews with 3 rows can be scrolled, sometimes not.
The intention, in my real code, is to put out a variable length list
in a grid fashion and it mostly works, but for the scrolling that is
sometimes required.

Is it possible to get the GridViews to come out full size, even at the
expense of all the item views in the ListView being larger? How could
I do that?

****** GridList.java *******

package com.example.gridlist;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class GridList extends ListActivity {

    private static final String[] STRINGS = {
            "one",
            "two",
            "three",
            "four",
            "five",
            "six",
            "seven",
            "eight",
            "nine",
            "ten",
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String[] satmp = {};            // These shouldn't be needed, but I get
a class cast exception
        String[][] saatmp = {{}};       // if I use ArrayList.toArray(),
instead of ArratList.toArray(T[])

        // Build an array of 10 string arrays, which range from length
zero to length 9
        ArrayList<String[]> strings_array = new ArrayList<String[]>();
        ArrayList<String> strings = new ArrayList<String>();
        for(int i = 0; i < 10; i++) {
                strings_array.add(strings.toArray(satmp));
                strings.add(GridList.STRINGS[i]);
        }
        MyArrayAdapter mAdapter = new MyArrayAdapter(this,
R.layout.grid, R.id.text1, strings_array.toArray(saatmp));
        this.setListAdapter(mAdapter);
    }

    // This is the "outer" adapter, the one for the ListView
        private class MyArrayAdapter extends ArrayAdapter<String[]> {

                public MyArrayAdapter(Context context, int textViewResourceId, 
int
textRes, String[][] objects) {
                        super(context, textViewResourceId, textRes, objects);
                }

                @Override
                public View getView(int position, View convertView, ViewGroup
parent) {
            LinearLayout ll;
            if (convertView == null) {
                ll = (LinearLayout) GridList.this.getLayoutInflater
().inflate(R.layout.grid, null);
            } else {
                ll = (LinearLayout) convertView;
            }
            TextView tv = (TextView) ll.findViewById(R.id.text1);
            tv.setText("Position #" + position);
            GridView gv = (GridView) ll.findViewById(R.id.gridview);
            GridAdapter ga = new GridAdapter(GridList.this,
android.R.id.text1, this.getItem(position));
            gv.setAdapter(ga);
            return ll;
        }
        }

        // This is the "inner" adapter, the one for the GridView
    private class GridAdapter extends ArrayAdapter<String>  {

                public GridAdapter(Context context, int textViewResourceId, 
String[]
objects) {
                        super(context, textViewResourceId, objects);
                }

                @Override
                public View getView(int position, View convertView, ViewGroup
parent) {
            TextView tv;
            if (convertView == null) {  // if it's not recycled,
initialize some attributes
                tv = new TextView(GridList.this);
            } else {
                tv = (TextView) convertView;
            }
            tv.setText(this.getItem(position));
            return tv;
        }
    }
}

****** AndroidManifest.xml ******

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.gridlist"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="Grid
List">
        <activity android:label="Grid List" android:name=".GridList">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="2" />
</manifest>


****** grid.xml ******

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
        <TextView
                android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
        />
        <GridView
            android:id="@+id/gridview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:numColumns="auto_fit"
            android:verticalSpacing="5sp"
            android:horizontalSpacing="5sp"
            android:columnWidth="90sp"
            android:stretchMode="columnWidth"
            android:gravity="center"
        />
</LinearLayout>

-- 

3. Emulator closes when attempting to enter full screen mode

4. awakenScrollBars() not showing scrollBar in custom View

5. Fwd: xor algorithm used when gc in dalvik

6. Playing Flash file in Android

7. URLconnection.setConnectTimeout doesn't work?