Application not found by queryIntentActivities

by DanH » Tue, 05 Oct 2010 02:18:06 GMT


Sponsored Links
 We have the following code:

                PackageManager packageManager = context.getPackageManager();
                Intent testIntent = new Intent(Intent.ACTION_VIEW);
                testIntent.setType("application/pdf");
                List<ResolveInfo> list =
packageManager.queryIntentActivities(testIntent,
PackageManager.MATCH_DEFAULT_ONLY);
                int pdfViewerCount = list.size();
                if (pdfViewerCount == 0) {
                   <print nasty message>
                }

For some reason, on an HTC Evo, this code returns zero for
pdfViewerCount when only the default PDF viewer is installed.  Here is
the default viewer:

Activity Resolver Table:
  Full MIME Types:
      application/pdf:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f819f0

  Base MIME Types:
      application:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f819f0

  Schemes:
      file:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f819f0
      content:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f819f0

  Non-Data Actions:
      android.intent.action.SEARCH:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f76eb0
      android.intent.action.MAIN:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f952c0
        45f696f8 com.htc.pdfreader/.MyFilePickerActivity filter
45f64d50

  MIME Typed Actions:
      android.intent.action.VIEW:
        45f9e688 com.htc.pdfreader/.ActPDFReader filter 45f819f0

Receiver Resolver Table:
  Schemes:
      file:
        45f3ef78 com.htc.pdfreader/.MediaBroadcastReceiver filter
45f3d1b0

Packages:
  Package [com.htc.pdfreader] (45fab438):
    userId=10077 gids=[]
    sharedUser=null
    pkg=Package{46275e58 com.htc.pdfreader}
    codePath=/system/app/PDFViewer.apk
    resourcePath=/system/app/PDFViewer.apk
    dataDir=/data/data/com.htc.pdfreader
    targetSdk=8
    supportsScreens=[medium, large, small, resizeable, anyDensity]
    timeStamp=1281017266000
    signatures=PackageSignatures{45fb6710 [45fb1780]}
    permissionsFixed=false haveGids=true
    pkgFlags=0x1 installStatus=1 enabled=0
    grantedPermissions:
      android.permission.MOUNT_UNMOUNT_FILESYSTEMS

Registered ContentProviders:
  [com.htc.pdfreader.PdfSuggestionProvider]: Provider{45f47660
com.htc.pdfreader.PdfSuggestionProvider}


Why would this viewer not be found???

(The meaning of MATCH_DEFAULT_ONLY is unclear to me, but it appears to
imply that only apps that would respond to a vanilla "click" on the
file in a file list should be selected.  Surely the default PDF viewer
would respond to this, no?)

--



Application not found by queryIntentActivities

by Mark Murphy » Tue, 05 Oct 2010 02:24:49 GMT


 


Have you tried with 0 in place of MATCH_DEFAULT_ONLY? Perhaps that
activity does not have the default category specified in its intent
filter.

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

Android Training...At Your Office:  http://commonsware.com/training 

--


Sponsored Links


Application not found by queryIntentActivities

by DanH » Tue, 05 Oct 2010 02:39:15 GMT


 Just tried it with zero.  Fails the same way.  (And the code works
fine on other phones.)






--



Application not found by queryIntentActivities

by DanH » Tue, 05 Oct 2010 02:44:10 GMT


 And, if we skip the test and let the code continue on, a PDF is
successfully displayed through a simple startActivity with an intent
for ACTION_VIEW on a PDF file.






--



Application not found by queryIntentActivities

by DanH » Tue, 05 Oct 2010 04:07:24 GMT


 Ran another experiment where I made the intent passed to query exactly
match the one that works to start the activity later.  Still no joy.






--



Application not found by queryIntentActivities

by DanH » Tue, 05 Oct 2010 04:47:48 GMT


 Well of course there was a coding error in that last experiment.  When
I pass a file with the intent then the HTC viewer is happy to
acknowledge its existence.  So to be reasonably certain of finding all
apps that can handle an intent apparently you have to create the
complete intent.







--



Application not found by queryIntentActivities

by Mark Murphy » Tue, 05 Oct 2010 05:04:09 GMT


 


It probably has a <data> element in its <intent-filter> that was not
matching your previous Intent.

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

Android Training...At Your Office:  http://commonsware.com/training 

--



Other Threads

1. Accessing APNs on the phone

Hello,

How can I get the information on this phone regarding its number, carrier,
etc?

I have tried this:

String names = "";

Uri contentUri = Uri.parse("content://telephony/carriers/");

Cursor cursor = null;
try
{
cursor = getContentResolver().query(contentUri, new String[]{"name"}, null,
null, null);
if (cursor != null)
{
while (cursor.moveToNext())
{
String name = cursor.getString(0);
names+= name + "\n";
}
}
}
catch (Exception ex)
{
//Handle exceptions here
}
finally
{
if (cursor != null) cursor.close();
}


tv.setText("TestActivity:\n"+names);

But no success.

I get on the emulator screen:
Android
TelKila

-- 

2. Why does TextView.setText cause the enclosing ScrollView to scroll?

Hello!

I'm new to this group and (full disclosure) cross posting this
question here from StackOverflow, just because I'm not 100% sure how
my question will be found by other SO users (I made sure to read the
suggested "How To Ask Questions The Smart Way", and made sure to
search SO for a clear explanation, but I must have missed it).  Here,
I'm clear that it'll be sent out to everyone, so here goes (my
apologies in advance if I shouldn't be cross-posting like this!)




I've got this odd problem which is happening on 1.6, 2.2, and a
MyTouch 3G Slide (which is API #7, and listed as "2.1-Update1" in the
Android Device Chooser).

The basic idea for my app is to make a stopwatch-sort of thing, in
that the user can tap a button to start a timer, then tap it again to
stop (pause) the timer; further taps alternate between resuming the
timer and pausing the timer.

I've got a top-level ScrollView which contains a RelativelLayout,
which contains a bunch of widgets.  The first widget is a HUGE button
(so that it's easy to press), which pushes all my other widgets below
the bottom of the screen.  This is intentional, as I want to rely on
the ScrollView (and an on-screen reminder to the user) to make the
rest of the input options available.

I've got a simple state-machine type setup, where mState is the
current mode (STATE_TIMER_NOT_STARTED before the user presses any
buttons, ...RUNNING after the first press, and then ...PAUSED after
the second, back to ...RUNNING after the third, etc, etc).

All this works great EXCEPT that when the timer is running, and the
user presses the start/stop/resume button again, the ScrollView will
scroll down a ways.  I am NOT issuing this command (I don't even have
a reference to ScrollView object), and I'm not sure why it's doing
this.

REPRO:
Compile + run the below samples.  When the app starts, press the
'Start Timing' button.  Use your thumb (or the mouse) to touch-drag
the screen upwards (so you can see the RatingBar), then drag it back
downwards (so the button is again completely on-screen).  Tap the
button (which now reads 'PauseTiming') again, and it'll jump down a
bit.  It should NOT be jumping/scrolling down, since there's no
statement (that I can see) that tells it to scroll down.  As near as I
can tell, it's the setText that causes the scrolling ( when I comment
those lines out, no scrolling occurs).

WHAT I'M ASKING FOR:
If I'm doing something dumb & you could point out what it is, I'd
really appreciate it! :)
***    I wonder if 'touch mode' might have something to do with this,
since it does NOT appear to happen (in the emulator) when I use the
mouse's scroll wheel to move the panel upwards (i.e.,instead of the
simulated finger-dragging).  I can't find a whole lot on touch-mode,
and nothing specific on focus/selection in touch mode within a
ScrollView

If you can confirm that this error occurs for you too, that would be
ok, too (since misery loves company.*AHEM* I mean, since it might help
confirm that it's not just me :)   ).



<b>MyTestApp.java</b>
<code>
package bug.android.scrollview;

import android.app.Activity;
import android.os.Bundle;
import android.text.format.Time;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

public class MyTestApp extends Activity {

        public final static int STATE_TIMER_NOT_STARTED = 1;
        public final static int STATE_TIMER_RUNNING = 2;
        public final static int STATE_TIMER_PAUSED = 3;
        private int mState;

        Time t = new Time();

        private Time data = new Time();

        private Button btnStartStopResume;
        private TextView lblSpacer;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.new_time_entry);

                btnStartStopResume = (Button) 
findViewById(R.id.btnStartStopResume);

                // Set the button's size so that the other info will also be 
visible
                Display display = ((WindowManager) 
getSystemService(WINDOW_SERVICE))
                                .getDefaultDisplay();
                // This is such a hack, but the windowScroller doesn't appear to
                // have a height at this point in the lifecycle (nor in 
'onResume' :
( )
                btnStartStopResume.setHeight(display.getHeight() - 200);

                lblSpacer = (TextView) findViewById(R.id.lblSpacer);

                reset();
        }

        public void doStartStopResume(View v) {
                if (mState == MyTestApp.STATE_TIMER_NOT_STARTED) {

                        mState = MyTestApp.STATE_TIMER_RUNNING;

                        data.setToNow();

                } else if (mState == MyTestApp.STATE_TIMER_RUNNING) {
                        mState = MyTestApp.STATE_TIMER_PAUSED;

                        String s = getString(R.string.add_scroll_down_to_add);
                        lblSpacer.setText(s);
                } else if (mState == MyTestApp.STATE_TIMER_PAUSED) {

                        mState = MyTestApp.STATE_TIMER_RUNNING;
                }
        }
        public void doReset(View v) {
        }

        public void doNewRunClick(View v) {
        }

        public void doAddTiming(View v) {
        }

        public void reset() {
                mState = STATE_TIMER_NOT_STARTED;
        }
}
</code>



<b>new_time_entry.xml</b>
<code>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/windowScroller"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        <RelativeLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
        >
                <Button
                        android:id="@+id/btnStartStopResume"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="5dip"
                        android:text="Start Timing"
                        android:textSize="40dp"
                        android:height="290dp"
                        android:onClick="doStartStopResume" />

                <TextView
                        android:id="@+id/lblSpacer"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/btnStartStopResume"
                        android:layout_centerHorizontal="true"
                        android:text="@string/add_scroll_down_for_more" />

                <TextView
                        android:id="@+id/lblTimeStartLabel"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblSpacer"
                        android:layout_alignParentLeft="true"
                        android:clickable="true"
                        android:onClick="adjustStartTime"
                        android:text="Start of this run:"
                        android:textSize="8dp" />

                <TextView
                        android:id="@+id/lblTimeStart"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblTimeStartLabel"
                        android:layout_alignParentLeft="true"
                        android:clickable="true"
                        android:onClick="adjustStartTime"
                        android:text="--:--:-- --"
                        android:textColor="#FFFFFF"
                        android:textSize="26dp" />

                <TextView
                        android:id="@+id/lblElapsedLabel"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblSpacer"
                        android:layout_alignRight="@id/lblSpacer"
                        android:layout_marginRight="5dp"
                        android:text="Elapsed Time:"
                        android:textSize="8dp" />

                <TextView
                        android:id="@+id/lblTimeElapsed"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblElapsedLabel"
                        android:layout_alignRight="@id/lblSpacer"
                        android:layout_marginRight="5dp"
                        android:textColor="#99ff66"
                        android:text="-- m -- sec"
                        android:textSize="26dp"
                        android:layout_marginBottom="10dip"/>

                <CheckBox
                        android:id="@+id/chkNewRun"
                        android:onClick="doNewRunClick"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblTimeElapsed"
                        android:text="This is a new run of timings"
                        android:layout_marginBottom="10dip" />

                <TextView
                        android:id="@+id/lblIntensity"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Intensity (1 = none 5 = max)"
                        android:layout_below="@id/chkNewRun" />

                <RatingBar
                        android:id="@+id/rbIntensity"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lblIntensity"
                        android:numStars="5"
                        android:rating="2"
                        android:layout_marginBottom="5dip" />

                <TextView
                        android:id="@+id/lblNotes"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Notes:"
                        android:layout_below="@id/rbIntensity" />

                <EditText
                        android:id="@+id/txtNotes"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        
android:background="@android:drawable/editbox_background"
                        android:layout_below="@id/lblNotes"
                        android:layout_marginBottom="10dip" />


                <Button
                        android:id="@+id/btnReset"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/txtNotes"
                        android:layout_alignParentLeft="true"
                        android:layout_marginLeft="10dip"
                        android:layout_marginRight="10dip"
                        android:text="Reset"
                        android:onClick="doReset" />

                <Button
                        android:id="@+id/btnOk"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/txtNotes"
                        android:layout_toRightOf="@id/btnReset"
                        android:layout_alignParentRight="true"
                        android:layout_marginLeft="10dip"
                        android:layout_marginRight="10dip"
                        android:text="Add Timing To List"
                        android:onClick="doAddTiming" />
        </RelativeLayout>
</ScrollView>
</code>


<b>strings.xml</b>
<code>
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Timer</string>
        <string name="dlg_edit_timing_title">Edit A Timing</string>
        <string name="add_scroll_down_for_more">&lt; Scroll down for more
options! &gt;</string>
        <string name="add_scroll_down_to_add">&lt; Scroll down to save this
timing! &gt;</string>
        <string name="start_timing">Start Timing\n\n</string>
        <string name="stop_timing">Pause Timing\n\n</string>
        <string name="resume_timing">Resume Timing\n\n</string>
</resources>

</code>

<b>AndroidManifest.xml</b>
<code>
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/
android"
        package="bug.android.scrollview"
        android:versionCode="1"
        android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".MyTestApp"
            android:label="@string/app_name">
            <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" /
            </intent-filter>
    </activity>
    </application>
    <uses-sdk android:minSdkVersion="5" />
    </manifest>
</code>

-- 

3. How to fetch phone's phone number or unique ID

4. The server could not process your apk. Try again.

5. Build-In Extensions

6. Google MapsAPI MyLocationOverlay causes ClassCastException

7. Software Design Description