Ok guys I'm super new at this, so bear with me...I'm basically reading a book on Android development, and following a tutorial in it.
This app has 7 activities (1 called QuizActivity that extends Activity, and 6 others that extend QuizActivity - 1 of which is QuizSplashActivity, the one I want to launch on startup)
However, I'm super confused as to why the default activity doesn't seem to be launching. My manifest has the correct tags for QuizSplashActivity, and QuizSplashActivity points to the correct .xml layout file I created. When I run the program, however, the console says:
[2013-03-11 17:19:47 - BeenThereDoneThat] Starting activity com.example.beentheredonethat.QuizActivity on device emulator-5554
[2013-03-11 17:19:48 - BeenThereDoneThat] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.beentheredonethat/.QuizActivity }
Here is the application section of the manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="QuizSplashActivity"
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="QuizActivity"></activity>
<activity android:name="QuizGameActivity"></activity>
<activity android:name="QuizHelpActivity"></activity>
<activity android:name="QuizMenuActivity"></activity>
<activity android:name="QuizScoresActivity"></activity>
<activity android:name="QuizSettingsActivity"></activity>
</application>
And here is my QuizSplashActivity, that I want to show on startup:
package com.example.beentheredonethat;
import android.os.Bundle;
import android.view.Menu;
public class QuizSplashActivity extends QuizActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_quiz, menu);
return true;
}
}
Any ideas as to why this is doing this? Any help would be greatly appreciated. Thanks!
I think that problem is your in manifest in declaring Activities. You are missing dot before Activity name:
android:name=".QuizSplashActivity"
and compilator can't find your Activity. Try to fix it and it should works. Also try to clean your project, restart Eclipse and try to start app again.
Related
Hello everyone this is my first android coding and im trying to switch between activities, but i cant simply find where is my mistake.
Main here;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
protected void start()
{
Intent k= new Intent(MainActivity.this, Try.class);
startActivity(k);
finish();
}
And My manifest is here and my second activity name is "Try";
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.ege.intent.Try"
android:label="#string/app_name" >
</activity>
</application>
Thanks.
I think;
May your class package name is wrong but there should be more information about crash.
Change android:name="com.example.ege.intent.Try"
with Try.class location, if it is same in Manifest.
Just try to Change android:name=".Try"
If you put your error or your log details, I can help you
the method "start()" is unused. use it in "onCreate()" method .
you may add a button . swtich activities by listening the click.
Where do you call start()?. Manifest seems okay but check if your package is right, anyway try would do the same, MainActivity lacks a closing semicolon }
I'm trying to figure out how to work with custom permissions in Android.
https://developer.android.com/guide/topics/manifest/manifest-intro.html#perms .
I found similar problems answered here but none of the answers worked for me...
I've created simple app with Android studio 2.1.1
package com.example.lukas.permtest;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
with manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lukas.permtest">
<permission android:name="com.example.lukas.permission.ACTIVITY_PERM"
android:label="#string/permlab_activity"
android:description="#string/permdesc_activity"
android:protectionLevel="normal"/>
<uses-permission android:name="com.example.lukas.permission.ACTIVITY_PERM"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:permission="com.example.lukas.permission.ACTIVITY_PERM">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have Sony Xperia Z2 tablet with Andoid 4.4.2 and Xperia Z3+ With Android 6.0
The app doesn't work. I get the same exception for both devices...
W/ActivityManager: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.lukas.permtest/.MainActivity } from ProcessRecord{44cf1178 2461:com.sonyericsson.home/u0a95} (pid=2461, uid=10095) requires com.example.lukas.permission.ACTIVITY_PERM
What am I doing wrong?
Thanks
Hah! That's pretty funny!
I believe that what is going on here is that, although you've done everything right as far as your process and the permission, you forgot one small thing...
The Launcher needs to start your app. The Launcher doesn't have your custom permission.
In other words, your application could launch its own MainActivity, because it has the permission to do so. The Launcher does not have the permission, so when it attempts to launch the android.intent.action.MAIN Activity, if fails for lack of permission.
Separate the Main Activity from the Activity protected by the permission. Launch the protected Activity from the Main Activity and everything go smooth as silk.
I'm an Android noob and I'm having difficulty finding out something basic about Android.
I currently have an activity_main.xml file.
I want to use this layout when I first start the Android emulator, using Android Studio
Does Android look for a file activity_main.xml and use it as the default layout?
Here's my AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
So I understand that this specifies that my .MainActivity will respond to an action.MAIN intent call. What I don't know is what the action.MAIN intent call actually is, and how my activity_main.xml relates to this.
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Can anyone provide an explanation or a link to a good primer that explains these basic concepts?
From manifest :
<action android:name="android.intent.action.MAIN" />
Means this activity is the entry point of the application. In your case, the MainActivity starts.
The MainActivity sets up the layout for itself - the line responsible is
setContentView(R.layout.activity_main);
Where it looks for layout file activity_main.xml. This is just the naming convention - feel free to rename the layout file and call the new one from setContentView. It's not required to be called activity_main
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am a newbie to android development and have little experience of eclipse. My android emulator is working properly but I cannot see application running on it.
Any pointers would be great. Thanks in advance.
MainACtivity.java
package com.example.helloworld;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.act`enter code here`ion_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<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>
</application>
</manifest>
use the
AndroidManifest.xml
file, you can actually even have more than one launcher activity specified in your application manifest. To make an activity seen on the launcher you add these attributes to your activity in the manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
set this inside your <activity> . hopefully it should work now. :)
I'm trying to create a simple app, whose main task is to open the browser on defined URL.
I've created first Activity:
public class MyActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
Intent myIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://my.url.tld"));
startActivity(myIntent);
}
Here's my AndroidManifest.xml:
<manifest ...>
<application ...>
<activity android:name=".MyActivity" ...>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
This code is fully functional, but before it opens the browser, it displays a black background - blank app GUI. I didn't figured out, how to go directly do the browser (without displaying the GUI).
Anyone knows?
Add this theme declaration to your activity definition in you manifest
<activity android:name=".MyActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
>
Be careful with this, you must call finish(); from your activity after you are done with it otherwise users could get stuck with an invisible activity that prevents them from interacting the phonetop.