No Activity found to handle Intent { act=android.intent.action.DELETE } - android

I am trying to write a code that shows a list of apps and lets the user choose an app to delete. I wrote this code based on what i've seen online:
appListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Uri packageUri = Uri.parse(names.get(position));
Intent uninstallIntent =
new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
startActivity(uninstallIntent);
}
});
However, for some reason I am getting this exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.UNINSTALL_PACKAGE dat=com.ivuu }
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INSTALL_PACKAGES"
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AppList"></activity>
</application>
I am pretty new to android and I spent the whole day on this... Please tell me what I am missing
Thanks

You do not have a scheme. Your Uri needs to be of the form package:..., where ... is the application ID/package name.

Related

How to open an activity in a package subfolder from another activity?

I have problem with my manifest. When I try to open the second Activity, I get the error android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION }
Find bellow my Manifest .xml contain
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxxxx.monapplication" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:supportsRtl="true" android:theme="#style/AppTheme" >
<activity android:name="com.xxxxx.monapplication.application.Accueil" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.xxxxx.monapplication.application.OwnerRegistration" >
<intent-filter>
<action android:name="android.intent.action.APPLICATION.OWNERREGISTRATION" />
<category android:name="android.intent.category.APPLICATION.DEFAULT" />
</intent-filter>
</activity>
An the part of my code to open second activity
btnMel.setOnClickListener( new View.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent i = new Intent("com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION");
startActivity(i);
}
}
Please help me to find the error.
You can call activity by its class name, then put your custom intent to setAction.
private String YOUR_ACTION = "com.xxxxx.monapplication.APPLICATION.OWNERREGISTRATION"
//uou can use this instead.
//Intent i = new Intent(this /* caller context */, OwnerRegistration.class);
Intent i = new Intent();
i.setAction(YOUR_ACTION);
startActivity(i);
try this code..
Intent myIntent = new Intent(YourActivity.this, OWNERREGISTRATION.class); startActivity(myIntent);

Android: ActivityNotFoundException

I'm new to android and java programming and I'm getting ActivityNotFoundException in my app.
Here these are the only two times the activity is called:
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
String selectedItem = (String) lvCheckLists.getItemAtPosition(position);
Intent i= new Intent("com.teamvdb.checklist.checkListActivity");
// Package name and activity
// Intent i= new Intent(MainActivity.this,SecondActivity.Class);
// Explicit intents
i.putExtra("selectedItem",selectedItem);
// Parameter 1 is the key
// Parameter 2 is your value
startActivity(i);
Intent openCheckListActivity = new ntent("com.teamvdb.checklist.checkListActivity");
startActivity(openCheckListActivity);
}
});
}
And here there is my Android Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teamvdb.checklist"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".checkListActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
I have spent the last 20 minutes trying to figure out what is wrong with it but I can't see the problem.
And yes the class is spelled correctly.
Explicitly start checkListActivity :
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String selectedItem = (String) lvCheckLists.getItemAtPosition(position);
Intent i= new Intent(MainActivity.this,checkListActivity.class);
i.putExtra("selectedItem",selectedItem);
startActivity(i);
});
intent-filter not required for checkListActivity so remove it and define as simple in AndroidManifest.xml :
<activity android:name=".checkListActivity"/>
Note : Remove unneccsary code which start checkListActivity again.

Android Studio, error with intents

I'm using Android Studio to write and run my android application but I run into this error when I try to go from one activity to another via intent, I either get this error:
android.content.ActivityNotFoundException: Unable to find explicit activity class
{com.example.rudrunk/junit.framework.Test}; have you declared this activity in your
AndroidManifest.xml?
or a NullPointerException if I use another intent.
My manifest file is below, but all the code comes from the IDE automatically, so I don't understand what's going on.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rudrunk"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:theme="#style/AppTheme" android:label="#string/app_name" android:icon="#drawable/ic_launcher" android:debuggable="true" android:allowBackup="true">
<activity android:label="#string/app_name" android:name="com.example.rudrunk.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="#string/title_activity_test" android:name="com.example.rudrunk.Test" />
<activity android:label="#string/title_activity_drunk_test" android:name="com.example.rudrunk.DrunkTest" />
</application>
Java Code for intents:
final Intent localIntent1 = new Intent(MainActivity.this, DrunkTest.class);
final Intent localIntent2 = new Intent(MainActivity.this, Test.class);
Button localButton1 = (Button)findViewById(R.id.maybe);
Button localButton2 = (Button)findViewById(R.id.yes);
localButton1.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramAnonymousView)
{
startActivity(localIntent1);
}
});
localButton2.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramAnonymousView)
{
Intent localIntent = new Intent("android.intent.action.CALL");
localIntent2.setData(Uri.parse("tel:16097212155"));
startActivity(localIntent2);
}
});
Looks like Test.class is being resolved into junit.framework.Test instead of your Activity. This could be a wrong import (import junit.framework.Test;?) but the sure way to make it work would be to use the full class name, i.e.
new Intent(MainActivity.this, com.example.rudrunk.Test.class);
In any case, it should match the class name in the AndroidManifest file.

Why Button click redirection for another xml page is not working?

I looked in to everything before ask this. I am implementing an application and new to android, I need to redirect to my mapview xml when login button click. So i have written the intent plus made the activity in manifest file and tried writing codes every possible different way. And the code doesn't give any errors. But my emulator stops after launching.
I know something is wrong but I can't figure it out. Any idea why that happens?
here is my code
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button=(Button)findViewById(R.id.loginbtn);
button.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
switch (v.getId()) {
case R.id.loginbtn:
Intent intent = new Intent (MainActivity.this, MapView.class);
startActivity (intent);
break;
default:
break;}
}
}
);
}
}
/*if(username.getText().toString()==""&&password.getText().toString()=="")
{
Intent i= new Intent("com.example.shaz.MAPVIEW");
startActivity(i);
}
else
{
txt.setText("False");
}
*/
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myname"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myname.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".mapView"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.myname.MAPVIEW" />
<category android:name="android.intent.category.DEFUALT" />
</intent-filter>
</activity>
</application>
</manifest>
I have also created an xml file for map called map_view in my layouts.
So in every where I searched this is how they say new intent is creating .
And the emulator works fine if I do something else than this redirection. SO what ever problem I got is within this redirection part.
DEFAULT is spelled incorrectly in your Manifest
Change:
<category android:name="android.intent.category.DEFUALT" />
for this:
<category android:name="android.intent.category.DEFAULT" />

How to launch an Android app without "android.intent.category.LAUNCHER"

I want to know how to launch an Android app without:
android.intent.category.LAUNCHER
Here is my AndroidManifest.xml:
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name = "android.intent.category.LAUNCHER" />
</intent-filter>
If removing line 3, the app will not be in the launcher. The question is: where and how can I launch this app in other way?
You'll need to use a BroadcastReceiver.
public class SafetyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
ActivityManager as = (ActivityManager) context
.getSystemService(Activity.ACTIVITY_SERVICE);
if (IsNavigationRunning(as)) {
Intent i = new Intent(context, VoiceActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
Manifest:
<application
android:icon="#drawable/fot"
android:label="#string/app_name" >
<activity
android:name="com.Safety.VoiceActivity"
android:launchMode="singleTop"
android:theme="#style/Theme.CompletelyTransparentWindow" >
</activity>
<receiver
android:name="com.Safety.SafetyReceiver"
android:process=":goodprocess" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
This is an example that starts when a text is received.
This would be better if you want to launch a custom activity, for example on a button press:
Button btn = (Button)findViewById(R.id.xBtn);
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v)
{
Intent intent = new Intent("it.prassel.vimsmediaplayer");
intent.setComponent(ComponentName
.unflattenFromString("it.prassel.vimsmediaplayer/it.prassel.vimsmediaplayer.MainActivity"));
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);
}
});
And this is the manifest associated with your custom activity:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.prassel.vimsmediaplayer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature android:glEsVersion="0x00020000" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="it.prassel.vimsmediaplayer.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="it.prassel.vimsmediaplayer" />
</intent-filter>
</activity>
</application>
</manifest>
Where
Intent intent = new Intent("it.prassel.vimsmediaplayer");
corresponds to the line
<action android:name="it.prassel.vimsmediaplayer" />
And
intent.setComponent(ComponentName
.unflattenFromString("it.prassel.vimsmediaplayer/it.prassel.vimsmediaplayer.MainActivity"))
corresponds to the 2 lines
package="it.prassel.vimsmediaplayer" the part before /
android:name="it.prassel.vimsmediaplayer.MainActivity" the part after /
Your custom activity will not appear neither in the Menu nor in the Recent Apps, it will be completely anonymous. Pay attention, if you wish to be the only one who can acced to your app, to give the intent-filter a meaningful name
I want to know how to launch an Android app without: android.intent.category.LAUNCHER
In Android, an Activity should be started by an Intent. Intents can start an Activity with startActivity(Intent myIntent), example:
Intent myIntent= new Intent(context, target_class.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
You must replace "myIntent", "context" (usually a "this") and the "target_class" with your variables, in order for this to work.
So, whenever you need your activity, call the Intent, ans the OS will resolve for the Activity
you can specify in your class.
For example on clicking of a button you want to go to some activity. so just write this code:
Button btn = (Button)findViewById(R.id.xBtn);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intnt = new Intent();
intnt.setAction(android.intent.action.MAIN);
intnt.setCategory(android.intent.category.LAUNCHER);
startActivity(intnt);
}
});

Categories

Resources