I made second activity with ImageButton. It was displayed fine with white space around. I want to make it not full screen. Here stackoverflow answers said add android:theme="#android:style/Theme.dialog". So now my manifest:
<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>
<activity
android:name=".Main2Activity"
android:theme="#android:style/Theme.Dialog" >
</activity>
</application>
But now app crashs when Main2Activity is called by startActivity. Why?
I think you might have extended the AppCompatActivity class or some other class for Main2Activity class..try extending only the Activity class for Main2Activity
Public class Main2Activity extends Activity
add this requestWindowFeature(Window.FEATURE_NO_TITLE); before loading the setcontent
You might have extended the AppCompatActivity class or some other class for Main2Activity class. If so, change
android:theme="#android:style/Theme.Dialog"
to
android:theme="#style/Theme.AppCompat.Dialog"
Then it will work perfectly.
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 am getting following exception
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.as.as/com.as.as.LoginActivity$myTask}; have you declared this activity in your AndroidManifest.xml?
No clue as to whats wrong in this
<application
android:name=".ObjectClass.AppController"
android:allowBackup="true"
android:icon="#drawable/app_logo"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
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=".PersonalDetails"
android:label="#string/title_activity_personal_details"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".SignUpRegistration.SignUp" />
<activity
android:name="com.intsig.ccrengine.ISCardScanActivity"
android:label="#string/app_name" />
First try to clean and build project again and then try.
If it's not working then append a full path to your LoginActivity.
For e.g. your package name is com.exmaple then you write in your manifest com.example.LoginActivity instead of just .LoginActivity.
Looks like you are creating the Intent in the wrong way.
From this line
Unable to find explicit activity class {com.as.as/com.as.as.LoginActivity$myTask};
You can tell that you are creating an intent which explicit target is the myTask class, when in reality you want to have the Activity class to be the target class.
Your creating activity code is wrong.
new Intent(getBaseContext(), myTask.class);
This code trying to open activity from myTask class. Guess you are waiting for following code:
new Intent(getBaseContext(), AnotherActivity.class);
Hi to android stack overflow communities,
I want to remove the action bar which contain the title and the three dots. I have tried some of the solutions such as android:theme="#android:style/Theme.NoTitleBar" but, the app went crash.
Is there any possible other solution? Thanks
This is the nuclear option.
Replace
public class MainActivity extends ActionBarActivity
with
public class MainActivity extends Activity
in all the Activitys where you don't want ActionBar.
And to remove the three-dots button, add
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
return false;
}
to your Activity.
Try this. This will work.
You have to use Activity not ActionBarActivity. So extends your javaclass from Activity. For removing the three dots remove onCreateOptionsMenu method from your Activity.
Create Your code like this
<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"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Enter this line android:theme="#android:style/Theme.Black.NoTitleBar" in Activity
You just need to call function
getActionBar().hide();
Tthis will hide action bar for you simply.
I have a problem with tabhost widget. I have some activities in tabs which are working fine. When I want to open a new activity from inside one of the tabs, runtime gives me the
Instrumentation.checkStartActivityResult(int, Object) line: 1504
ActivityNotFoundException
I put the activity in the manifest file and it's ok(I can run it if i put it in a tab). But when i try to fire the activity from another activity which is currently in one of the tabs, it get this exception. Any help is appreciated.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".CoaActivity"
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=".MainMenu"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".favorites"></activity>
<activity android:name=".FoodMenu"></activity>
<activity android:name=".Info"></activity>
<activity android:name=".Restaurants"></activity>
<activity android:name=".Home"></activity>
<activity android:name=".RestaurantInfo"></activity>
</application>
favorites, foodmenu, info, restaurants, home have their own tabs. But restaurant info doesnt have its own tab. And when i try to run restaurant info by an intent I have the exception.
I found a solution for my problem. You have to use a ActivityGroup object, that fires other Intent objects. There is a little bit tutorial here : http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity. Hope it helps..
Just started working with android and ran into a small problem. I am have a TabActivity that is loading 3 other Activity classes. This works great. I then have a button on the other Activity classes that I would like to launch a MapActivity. When I do that I keep getting a Force Close.
I googled but I cannot figure out if it is the manifest file or something else. The idea is the tabs are showing location information and you click a button to plot it on the map and get directions.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_tab);
...
Button btnMap = (Button) findViewById(R.id.btnLaunchMap);
btnMap.setOnClickListener(mMapListener);
}
private OnClickListener mMapListener = new OnClickListener() {
public void onClick(View v) {
Intent mapIntent = new Intent(getApplicationContext(),LocationMap.class);
startActivity(mapIntent);
}
};
If I launch any other activity it works but not launching the mapactivity. If I take the mapactivity class and put it in a new project it works.
My manifest
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Locations"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationNewYork"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".LocationChicago"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationSeattle"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"></activity>
<activity android:name=".LocationMap"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<uses-library android:name="com.google.android.maps"/>
</application>
thougths?
<action android:name="android.intent.action.MAIN" />
inside of the mapactivity's instance ACTIVITY field in the Manifest file does it.
So if you have a MapActivity named QMap, the following code in the Manifest actually works:
<activity android:name=".QMap"><action android:name="android.intent.action.MAIN" /></activity>
Hope it helped
I had the same problem, wanted to launch map activity from an other activity over onClick-event, the problem was: errors in the MapActivity
If you are using eclipse try to run "debug as" without setting any breakpoints