I have an android project for first time installation.
It is related with my firm agreement pages. It comes after google agreement pages.
I tried some technics for doing it. For example,I set it as a system application. However, it is cleaned when backup and reset operation.
Does anybody know how to run it?
on AndroidManifest.xml
<application
android:theme="#android:style/Theme.NoTitleBar"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/appname" >
<activity
android:name="xxxagreement.MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter android:priority="3">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
on MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
protected void onResume() {
Intent i = new Intent();
i.setAction(AGREEGATE_STARTED);
sendBroadcast(i);
TextView t = (TextView)findViewById(R.id.textView1);
t.setSelected(true);
...
super.onResume();
}
Event Log prints:
Session 'app': Error Launching activity
Your application doesn't have any launcher activity. Replace these lines
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
with
<category android:name="android.intent.category.LAUNCHER" />
Related
I have two applications, the first one send an implicit intent to view a link and the second one named "MyBrowser" receives it. But when I install both apps on my phone (API level 23), the app chooser only display the Internet (default application for web viewing). If I use the AVD (API level 25), app chooser includes also "MyBrowser". Here is my first application's function:
private void startImplicitActivation() {
Log.i(TAG, "Entered startImplicitActivation()");
// Create a base intent for viewing a URL
Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
// Create a chooser intent, for choosing which Activity
// will carry out the baseIntent
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
// Verify the intent will resolve to at least one activity
if (baseIntent.resolveActivity(getPackageManager()) != null) {
Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction());
// Start the chooser Activity, using the chooser intent
startActivity(chooserIntent);
}
And "MyBrowser" Manifest.xml:
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MyBrowserActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent-filter>
</activity>
</application>
I am newbie in android and can't understand why. Please explain to me. Thank you.
Still a little bit new to Android studio and app development. On this project: https://github.com/watabou/pixel-dungeon, which file is acting as the MainActivity.java file? As in, which file is the main launcher of the application, how do you tell?
The activity with the intent filters android.intent.action.MAIN and android.intent.category.LAUNCHER is the launcher for any app,
Just check which activity it has bellow intent filter that is launcher,
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In that project PixelDungeon is the launcher activity.
Your launcher activity is defined in your android manifest (AndroidManifest.xml), it should look like this:
<activity
android:name=".activity.Login_screen"
android:label="Activity Validation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
For your case, if you want to edit your launcher activity just change ".activity.Login_screen" for the activity you want to display on launch. However, make sure that there are no duplicate definitions.
As you can see in your code:
<activity
android:label="#string/app_name"
android:name=".PixelDungeon"
android:screenOrientation="portrait">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I can not disable home button and Which is next to it in android I tried this code but does not work
#Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
Do you have any idea for solve this problem?
Or Can I hide navigation bar permanently forever؟
Can I hide navigation bar permanently forever?
No, system would not allow you to do so. But you can prevent the app from exiting.
Do the following in your onPause() method.
#Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
You need the following permissions
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.REORDER_TASKS" />
I found it.
I took a part from here
how to disable home button in android?
and added one row Which originally existed
LAUNCHER row as follow:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Recently I'm building a AOSP ROM from source. What I wanted to do is, add a 3rd party application into Settings app and It should be launched only from Settings and it should be invisible from Launcher.
Here's what I did, It fails everytime.
Removed these lines from apps AndroidManifest.xml
android:name="android.intent.category.LAUNCHER" />
and added below lines in SettingsActivity.java from Settings app.
if (KA_FRAGMENT.equals(fragmentName)) {
Intent kaIntent = new Intent();
kaIntent.setClassName("com.cyborg.manager", "com.cyborg.manager.activities.MainActivity");
startActivity(kaIntent);
finish();
return null;
}
Also added below lines in AndroidManifest.xml of Settings
<activity android:name="Settings$KActivity"
android:label="#string/hit_perform"
android:icon="#drawable/hit_performance_icon"
android:taskAffinity="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
<intent-filter android:priority="1">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.urom" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.ka" />
</activity>
Although, it works fine when 3rd party app is visible in launcher
If you want to play with custom ROM I'd recommend getting familiar with Android fundamentals first.
What makes you activity shown by launcher is this <intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
especially these two lines:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
so remove them and you are done.
I succeed to add my app in the "share" button in the Android gallery, so if I click on it, my app will start. Can I choose which activity of my app to start?
Now it starts the "main" one. Here's my code in the main class:
.....
Intent intent = getIntent();
Bundle extras = intent.getExtras();
String action = intent.getAction();
// if this is from the share menu
if (Intent.ACTION_SEND.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
// Get resource path
}
}
And the manifest:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
In reality I succeed in opening a new activity immediately after the "main" starts but I'll prefer to directly open the right one.
Thanks
Put your intent filter under activity you want to start into your manifest
<activity android:name=".Theme"
android:label="MAIN">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Theme"
android:label="ActiVITY2">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
If you had two activities in your manifest file, say Main and MediaShare then it would look something like this:
<activity android:name="Main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="MediaShare" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
The android.intent.action.SEND action and android:mimeType="image/*" data should go with the activity you want to start when you share an image.
See the page on Receiving Content from Other Apps for more details.