Activity chooser menu problem : Dialing a number - android

This code makes call successfully from my app
Intent dialer = new Intent("android.intent.action.CALL_PRIVILEGED");
mail.setData(Uri.parse("tel:65465446"));
startActivity(dialer);
But when trying to use an activity chooser like this:
Intent dialer = new Intent("android.intent.action.CALL_PRIVILEGED");
dialer.setData(Uri.parse("tel:65465446"));
Intent chooser = null;
chooser = Intent.createChooser(dialer,"Select Dialing Software...");
startActivity(chooser);
it throws following Logcat error if I select Dialer option, whereas SkypeOut works just fine
E/AndroidRuntime( 384): FATAL EXCEPTION: main
E/AndroidRuntime( 384): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL_PRIVILEGED dat=tel:65465446 flg=0x3000000 cmp=com.android.phone/.PrivilegedOutgoingCallBroadcaster } from ProcessRecord{44f4de30 384:com.dialer/10036} (pid=384, uid=10036) requires android.permission.CALL_PRIVILEGED
E/AndroidRuntime( 384): at android.os.Parcel.readException(Parcel.java:1247)
E/AndroidRuntime( 384): at android.os.Parcel.readException(Parcel.java:1235)
E/AndroidRuntime( 384): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
E/AndroidRuntime( 384): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
E/AndroidRuntime( 384): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 384): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 384): at com.android.internal.app.ResolverActivity.onClick(ResolverActivity.java:190)
E/AndroidRuntime( 384): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:874)
E/AndroidRuntime( 384): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 384): at android.widget.ListView.performItemClick(ListView.java:3382)
E/AndroidRuntime( 384): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/AndroidRuntime( 384): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 384): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 384): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 384): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 384): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 384): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 384): at dalvik.system.NativeStart.main(Native Method)
manifest has <uses-permission android:name="android.permission.CALL_PRIVILEGED"/> added
Thanks for your any help.

Do you need to make use of CALL_PRIVILEGED? I think the only difference versus CALL_PHONE is that it can call emergency numbers (65465446 does not look like one). Replace it all with CALL_PHONE and it will work just fine, I believe.

Related

ActivityNotFoundException when include Android library

I have a test project which uses OI FileManager. I added that project to my test project as an Android library, then I call an Activitity in the library. It shows error:
E/AndroidRuntime( 1359): FATAL EXCEPTION: main
E/AndroidRuntime( 1359): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.filemanager.FileManagerActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1359): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1359): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1359): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1359): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1359): at com.androidcoretest.FileExplorerTest$1.onClick(FileExplorerTest.java:24)
E/AndroidRuntime( 1359): at android.view.View.performClick(View.java:2408)
E/AndroidRuntime( 1359): at android.view.View$PerformClick.run(View.java:8816)
E/AndroidRuntime( 1359): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 1359): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1359): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1359): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1359): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1359): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1359): at dalvik.system.NativeStart.main(Native Method)
When I add full path of that Activity in the Manifest, it generates another error.
<activity
android:label="#string/app_name"
android:name="org.openintents.filemanager.FileManagerActivity" >
</activity>
It shows:
E/AndroidRuntime( 1393): FATAL EXCEPTION: main
E/AndroidRuntime( 1393): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidcoretest/org.openintents.filemanager.FileManagerActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 1393): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 1393): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 1393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 1393): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1393): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1393): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1393): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 1393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 1393): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 1393): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.androidcoretest/org.openintents.distribution.EulaActivity}; have you declared this activity in your AndroidManifest.xml?
E/AndroidRuntime( 1393): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
E/AndroidRuntime( 1393): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
E/AndroidRuntime( 1393): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/AndroidRuntime( 1393): at android.app.Activity.startActivity(Activity.java:2923)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.startForwardActivity(EulaOrNewVersion.java:127)
E/AndroidRuntime( 1393): at org.openintents.distribution.EulaOrNewVersion.showEula(EulaOrNewVersion.java:69)
E/AndroidRuntime( 1393): at org.openintents.distribution.DistributionLibrary.showEulaOrNewVersion(DistributionLibrary.java:53)
E/AndroidRuntime( 1393): at org.openintents.filemanager.FileManagerActivity.onCreate(FileManagerActivity.java:312)
E/AndroidRuntime( 1393): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 1393): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 1393): ... 11 more
W/ActivityManager( 59): Force finishing activity com.androidcoretest/org.openintents.filemanager.FileManagerActivity
I would say this is a bug of Eclipse. Eclipse and ADT recently have many bugs on building process: ClassNotFound and ActivityNotFound.
Update:
My code just use one line:
final Intent intent = new Intent(FileExplorerTest.this, FileManagerActivity.class);
startActivity(intent);
Actually I have 3 projects. 2 library projects and 1 test project. Library "OI File Manager" uses Library "OI Distribution", then the test project C uses library "IO File Manager".
Ensure you are linking the OI FileManager projects as a library rather than external jar. go to Project properties > Android > Library, then click add library.
Then as you are doing define the activity in your project manifest (however with ADT 20 i think this is automatic)
<activity
android:label="#string/app_name"
android:name="org.openintents.filemanager.FileManagerActivity" >
</activity>
I guess it can't find com.androidcoretest/org.openintents.distribution.EulaActivity not the FileManager activity. Do you have that EulaActivity in the manifest?
See in your log:
Caused by: android.content.ActivityNotFoundException: Unable to find
explicit activity class
{com.androidcoretest/org.openintents.distribution.EulaActivity}; have
you declared this activity in your AndroidManifest.xml?

Intent.ACTION_VIEW crashes with android.content.ActivityNotFoundException

I assume that you can open images from your resources folder with Intent.ACTION_VIEW?
If not then let me know, and don't bother reading on! haha
If you can then I have this code:
Intent mainIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);
mainIntent.setDataAndType(uri, "image/jpg");
startActivity(mainIntent);
And yet it is giving me this error:
E/AndroidRuntime( 309): FATAL EXCEPTION: main
E/AndroidRuntime( 309): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.tclayson.myapp/2130837611 }
E/AndroidRuntime( 309): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
E/AndroidRuntime( 309): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
E/AndroidRuntime( 309): at android.app.Activity.startActivityForResult(Activity.java:3190)
E/AndroidRuntime( 309): at android.app.Activity.startActivity(Activity.java:3297)
E/AndroidRuntime( 309): at com.tclayson.myapp.FBRadioPlayer$SlidingContentPagerAdapter$5.onItemClick(TheActivity.java:226)
E/AndroidRuntime( 309): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
E/AndroidRuntime( 309): at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
E/AndroidRuntime( 309): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
E/AndroidRuntime( 309): at android.widget.AbsListView$1.run(AbsListView.java:3168)
E/AndroidRuntime( 309): at android.os.Handler.handleCallback(Handler.java:605)
E/AndroidRuntime( 309): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 309): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 309): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 309): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 309): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 309): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 152): Force finishing activity com.tclayson.myapp/.MyActivity
I have no idea what could be wrong with this! Any help would be brilliant.
Thanks
What means the scheme 'android.resource' ? I have never seen before. Your error message means no Application is found that can handle your URI scheme.
I couldn't find the answer to this. So I created my own image viewer in the app.
You should add http:// at the beginning of the URL. ie. use
Uri uri = Uri.parse("http://android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);
instead of
Uri uri = Uri.parse("android.resource://com.tclayson.myapp/"+extrasImgs.mImagesIds[position]);

Navit Excepition:java.lang.ExceptionInInitializerError

While running the Navit code for car navigation, I am getting the following exception, i thought that navit library is not available. please any one help me.
E/AndroidRuntime( 365): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 365): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 365): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 365): at java.lang.Class.newInstance(Class.java:1472)
E/AndroidRuntime( 365): at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
E/AndroidRuntime( 365): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
E/AndroidRuntime( 365): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 365): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
E/AndroidRuntime( 365): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
E/AndroidRuntime( 365): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 365): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 365): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 365): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 365): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
E/AndroidRuntime( 365): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 365): Caused by: java.lang.UnsatisfiedLinkError: Library navit not found
E/AndroidRuntime( 365): at java.lang.Runtime.loadLibrary(Runtime.java:489)
E/AndroidRuntime( 365): at java.lang.System.loadLibrary(System.java:557)
i downloaded the Navit code from , navit svn.ttps://navit.svn.sourceforge.net/svnroot/navit/trunk/navit But unable to run the code.
i want to run this code in Eclipse for Android Project.
You need to download Android NDK
Create standalong tools for your ARCH
Cross compile to ARM
Run make apkg
This error is due to missing libnavit.so.
Put libnavit.so it in /data/local
Change System.LoadLibrary to System.Load("/data/local/libnavit.so");
make apkg
Install
This exception should go away.

Reading PhoneLookup.NUMBER crashing application in Android [duplicate]

This question already has answers here:
How to read contacts on Android 2.0
(9 answers)
Closed 5 years ago.
The following is my code:
Cursor mCursor = this.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.HAS_PHONE_NUMBER + "==1", null, null);
startManagingCursor(mCursor);
ListAdapter adapter = new SimpleCursorAdapter(this,
R.layout.two_line_list_item, mCursor, new String[] {
PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER}, new int[] {R.id.text1, R.id.text2});
setListAdapter(adapter);
I'm able to see the DISPLAY_NAME, but whenever I add PhoneLookup.NUMBER, the application crashes. I also added a condition to select only contacts that have a phone number assuming its crashing due to null data. Still no luck. Is there any permissions I need to add to get the phone number? I already have android.permission.READ_CONTACTS in my manifest.
Logcat output:
I/ActivityManager( 58): Starting activity: Intent { cmp=fourth.app/.food }
D/AndroidRuntime( 335): Shutting down VM
W/dalvikvm( 335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 335): FATAL EXCEPTION: main
E/AndroidRuntime( 335): java.lang.RuntimeException: Unable to start activity ComponentInfo{fourth.app/fourth.app.food}: java.lang.Ille
galArgumentException: column 'number' does not exist
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
E/AndroidRuntime( 335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 335): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 335): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 335): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 335): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 335): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 335): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 335): Caused by: java.lang.IllegalArgumentException: column 'number' does not exist
E/AndroidRuntime( 335): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
E/AndroidRuntime( 335): at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:99)
E/AndroidRuntime( 335): at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:312)
E/AndroidRuntime( 335): at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:87)
E/AndroidRuntime( 335): at fourth.app.food.onCreate(food.java:21)
E/AndroidRuntime( 335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
E/AndroidRuntime( 335): ... 11 more
W/ActivityManager( 58): Force finishing activity fourth.app/.food
W/ActivityManager( 58): Force finishing activity fourth.app/.four
W/ActivityManager( 58): Activity pause timeout for HistoryRecord{43f54e88 fourth.app/.food}
java.lang.IllegalArgumentException: column 'number' does not exist
You are using an invalid name of column.
have a look at this question: How to read contacts on Android 2.0

VerifyError When Running jUnit Test on Android 1.6

Here's what I'm trying to run on Android 1.6:
package com.healthlogger.test;
public class AllTests extends TestSuite
{
public static Test suite()
{
return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build();
}
}
and:
package com.healthlogger.test;
public class RecordTest extends AndroidTestCase
{
/**
* Ensures that the constructor will not take a null data tag.
*/
#Test(expected=AssertionFailedError.class)
public void testNullDataTagInConstructor()
{
Record r = new Record(null, Calendar.getInstance(), "Data");
fail("Failed to catch null data tag.");
}
}
The main project is HealthLogger. These are run from a separate test project (HealthLoggerTest). HealthLogger and jUnit4 are in HealthLoggerTest's build path. jUnit4 is also in HealthLogger's build path. The class "Record" is located in com.healthlogger.
Commenting out the "#Test..." and "Record r..." lines allows this test to run. When they are uncommented, I get a VerifyError exception. I am severely blocked by this; why is it happening?
EDIT: some info from logcat after the crash:
E/AndroidRuntime( 3723): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3723): java.lang.VerifyError: com.healthlogger.test.RecordTest E/AndroidRuntime( 3723): at java.lang.Class.getDeclaredConstructors(Native Method)
E/AndroidRuntime( 3723): at java.lang.Class.getConstructors(Class.java:507) E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.hasValidConstructor(TestGrouping.java:226)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:215)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:211)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.select(TestGrouping.java:170) E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:160)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115)
E/AndroidRuntime( 3723): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103)
E/AndroidRuntime( 3723): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:321)
E/AndroidRuntime( 3723): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3848)
E/AndroidRuntime( 3723): at android.app.ActivityThread.access$2800(ActivityThread.java:116) E/AndroidRuntime( 3723): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
E/AndroidRuntime( 3723): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3723): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 3723): at android.app.ActivityThread.main(ActivityThread.java:4203)
E/AndroidRuntime( 3723): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3723): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime( 3723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) E/AndroidRuntime( 3723): at dalvik.system.NativeStart.main(Native Method)
This can occur when you forget to export all dependencies for a test project.
In Eclipse, go to the Java Build Path properties for your projects (both the main project and the test project). Go to the Organize/Export tab and make sure you check all dependencies (select all, except for any JRE or Classpath Container that might be listed).

Categories

Resources