Android Manifest intent issues - java

In this app I want a button press to open a different Java file now I have done this many times before but I can't seem to get it to work now. i was just wondering if anyone can see what i have done wrong
this is my manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ucas.course"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SQLView"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.SQLVIEW" />
<category android:name="android.intent.category.OTHER" />
</intent-filter>
</activity>
</application>
</manifest>
and this is how I start the intent
public void onClick(View v) {
if(v.getId() == R.id.button1) {
Intent temp = new Intent("android.intent.action.SQLVIEW");
startActivity(temp);
}
}

There is no android.intent.category.OTHER, you probably meant android.intent.category.DEFAULT.

Related

Android: No Launcher activity found! Did check LAUNCHER

So most responses told me to check that there's an activity with the category set to LAUNCHER. I have 2 activities - one starting the other, and 2 .xml layout files (for each of the activities)- I get the "No Launcher activity found" when trying to run on emulator.
This is my manifest-file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dk.orbliners.workout"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<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="dk.orbliners.workout.MainActivity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="SecondaryActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="dk.orbliners.workout.SecondaryActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
For your main activity you need something like this:
<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>

android.permission.RECEIVE_BOOT_COMPLETED does not launch activity at boot

I have a BootUpReceiver class which I'm attempting to use with RECEIVE_BOOT_COMPLETED to launch an Activity when the device boots. The problem is - it does not seem to do so when I launch the app then restart the device.
I have verified there is no issue running Activity1.java - the issue lies either in the Manifest or the BootUpReceiver class but I'm not sure exactly why it will not launch after rebooting.
BootUpReceiver.java:
public class BootUpReceiver extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, Activity1.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.com.idg.voiscphone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.idg.voiscphone.Activity1"
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="com.idg.voiscphone.Activity2"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3a"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3b"
android:label="#string/app_name" >
</activity>
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
Example Source:
http://androidrocksonmobility.blogspot.com/2012/01/how-to-create-auto-start-android.html
Remove android:permission="android.permission.RECEIVE_BOOT_COMPLETED" and try again.
Beyond that, there is no requirement that your activity appear in front of any other activity that might be started around the same time, such as the home screen.

how to call activity from application class

i have got an controller which is inherited by application, i have also set it in manifest file. now i want to call a activity from here. i'm not getting how to do?
Here how i'm trying, but it fails
public class SampleApplication extends android.app.Application {
public SampleApplication() {
// TODO Auto-generated constructor stub
Context context = SampleApplication.this.getApplicationContext();
Intent intent = new Intent();
intent.setClass(context, MainActivity.class);
startActivity(intent);
}
My manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sampleapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:name="SampleApplication"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.sampleapp.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>
</application>
</manifest>
You can do what you are trying to do by simply using the AndroidManifest.xml file :
<activity android:name="Activity name" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

My app doesn't show on emulator, when I run the project

when I try to run the project it installs successfully on an emulator, but emulator does not show my app launcher icon in its app menu. but however it shows my app in installed apps in setting>applications>manage applications>all apps , so that means that an app was installed. but it didn't run.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thenewboston.travis"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.SPLASH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Make sure your starting activity has its intent-filter declared properly in your manifest to be shown in the launcher.
Assuming you want "Splash" to be your main activity change its declaration to this (specifically the intent-filter action)
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Your intent filter action was not part of the android defaults (and what launchers normally look for). Only launchers that were designed to look for the action "com.thenewboston.travis.SPLASH" would see your activity
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.thenewboston.travis.SPLASH" /> //try "android.intent.action.MAIN" here//
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

What's wrong with this Java code? Android?

the purpose of this activity/program is to simply switch from this activity to another one using a button. From IzzynActivity to notes. Here is the android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="izzy.n"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And here is the IzzynActivity.java code:
package izzy.n;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class IzzynActivity extends Activity{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button wg = (Button) findViewById(R.id.button1);
wg.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(IzzynActivity.this, notes.class);
IzzynActivity.this.startActivity(myIntent);
}
});
}
}
An activity cannot contain another activity in the AndroidManifest.xml file. Here's the right code:
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="izzy.n.IzzynActivity"
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="izzy.n.notes"
android:label="#string/notes"></activity>
</application>
</manifest>
Note:
If you return anything with setResult() from a started activity you should start it using startActivityForResult.
For the warning message:
Just edit one piece of code and re-run your application. It will be reinstalled on the phone and you should not see the warning message again.
For one you have an activity tag inside another activity tag in your manifest which is clearly wrong.
Change your manifest to this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="izzy.n"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".IzzynActivity"
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=".notes"
android:label="#string/notes">
</activity>
</application>
</manifest>
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
you are declareing an activity inside another activity without closing first one: so replace this block with:
<activity
android:name="izzy.n.IzzynActivity"
android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="izzy.n.notes"
android:label="#string/notes"></activity>
<intent-filter>
</activity> closing tag for your first activity should come before starting tag for your second activity. You are nesting your activities, which is not permitted.

Categories

Resources