organize activities in a folder - android-activity

Hi I'm building my first android app, i like to have separate files for each class in my Android projects.
now i have:
src-->com-->quickorder-->activities
(in this folder i want to put all my activity files)
src-->com-->quickorder-->activities-->MainActivity.java
src-->com-->quickorder-->activities-->DbSincroActivity.java
manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.quickorder"
android:versionCode="1"
android:versionName="1.0">
<activity
android:name=".activity.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=".activity.DbSincroActivity"></activity>
MainActivity.java
package com.quickorder;
public class MainActivity extends Activity {
....
....
}
is this a correct statement?

No, you have
android:name=".activity.MainActivity"
you need to refer to the activities sub-root such as
android name=".activities.MainActivity"
Manifest takes that dot to mean that it's a subfolder of your package that you declared.

Related

Why unityplayer.SkipPermissionsDialog not working with unity 2018.3.14?

I'm develop application with unity and vuforia and I use
<meta-data android:name=“unityplayer.SkipPermissionsDialog” android:value=“true”>
in Manifest.xml to skip permission on startup.My application export (apk) in unity 5.1.1 work fine but not working in untiy 2018.3.14.I'm going to create another project with unity 2018.3.14 and edit the manifest.xml with line on above, but it still ask for camera permission on startup.
This is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unity3d.player"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="preferExternal">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:theme="#style/UnityThemeSelector"
android:icon="#mipmap/app_icon"
android:label="#string/app_name">
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:label="#string/app_name"
android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<!-- For Runtime Permission -->
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
<activity android:name="com.onevcat.uniwebview.UniWebViewFileChooserActivity" />
</application>
</manifest>
Any help please?
First guess
Unity won‘t ask for permission directly after the app start anymore, if you set unityplayer.SkipPermissionsDialog.
But Vuforia will do request a runtime permission dynamically the moment it an AR Camera is enabled.
I‘m guessing that you are using an AR Camera in you first scene?
update 1
Try moving unityplayer.SkipPermissionsDialog in the AndroidManifest.xml inside the activity tag instead of the application tag.
So, I try another way to solve problem.
1- Check the Delayed Initialization box (Window->Vuforia Configuration).
2- Use the <meta-data android:name=“unityplayer.SkipPermissionsDialog” android:value=“true”> normally and ask for permissions when I need those.
3- Add this line of code to the Start() function of this new script and assign it to empty gameobject:
VuforiaRuntime.Instance.InitVuforia();
4- So, when user allow for permission, I load 2nd Scene and it run Vuforia initialize.

Setting-up ARcore with Vuforia

Hi im new to Unity3d and AR, and i need to setup Arcore to use with vuforia.
i already have the " core-1.7.0.aar " file in Assets/Plugins/Android folder
and i already set the AndroidManifest.XML in the same folder as the .aar file
<application android:theme="#style/UnityThemeSelector" android:icon="#mipmap/app_icon" android:label="#string/app_name">
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="#string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<meta-data android:name="unity.build-id" android:value="53bad2ba-a78a-4c14-9e44-e3d1cbb2f87c" />
<meta-data android:name="unity.splash-mode" android:value="0" />
<meta-data android:name="unity.splash-enable" android:value="True" />
<!-- The following must be present to facilitate use of ARCore, if available -->
<meta-data android:name="com.google.ar.core" android:value="optional" />
</application>
and according to Vuforia Guide i need to edit the Build.gradle but i dont know How to do that from unity?
and also after i set this up, will the tracking be as good as ARcore or no?
Thank you.
You can export your project from Unity to Android Studio by selecting Export Project in the Build Settings window then press Build. Unity will ask where you want to save the output. This will give you access to all the Gradle files to follow the instructions provided by Vuforia.

Eclipse imported but default activity not found

I just imported my eclipse project to android studio, and It studio converted everything fine. But while running the error message shows: Default Activity Not Found.
my manifest file: https://hastebin.com/yigakupoho.xml
You need to define your default activity as android.intent.action.MAIN, like that:
<activity android:name=".YourActivity" android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

Unity firebase notifications custom image

I have decided to implement Firebase notifications into my unity project. The issue is that for notifications I want to use custom image, but that image is also used as app image (app_icon). I tried to modify manifest where I put into MessagingUnityPlayerActivity activity custom notification image (notificon) for displaying notification icon.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="${applicationId}"
android:versionCode="1"
android:versionName="1.0">
<application android:label="#string/app_name"
android:icon="#drawable/app_icon">
<!-- The MessagingUnityPlayerActivity is a class that extends
UnityPlayerActivity to work around a known issue when receiving
notification data payloads in the background. -->
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity"
android:label="#string/app_name"
android:icon="#drawable/notificon"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<service android:name="com.google.firebase.messaging.MessageForwardingService"
android:exported="false"/>
</application>
</manifest>
I tried to modify it and delete some tags, but then the build wond compile. I should also mention that I have multiple manifests in my project and tried them to merge together but unsuccessfully. But this shouldnt be the problem since this is the only manifest with android:icon propery.
Thank you
Make an image (a white on transparent version of game icon, png) under folder "Assets\Plugins\Android\res\drawable.
In my case, the name of my image is "small_icon.png" then in "Assets\Plugins\Android\AndroidManifest.xml", add it after opening tag:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/small_icon" />
Your AndroidManifest.xml should be like
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="${applicationId}"
android:versionCode="1" android:versionName="1.0">
<application android:label="#string/app_name" android:icon="#drawable/app_icon">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/small_icon" />
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
....
Putting a res folder inside Assets/Plugins/Android using AAB is obsolete and will prevent you from building.
Since I was too lazy to install Android Studio to build a custom AAR I solved it by placing a ZIP-Archive into the Assets/Plugins/Android folder, with the res folder inside (res folder created with this as mentioned in an other answer) and the following snippet inside a AndroidManifest.xml next to the res folder:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.firebase.messaging"
android:versionCode="1"
android:versionName="1.0">
<application>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/YOURICONIMAGENAMEWITHOUTEXTENSION" />
</application>
</manifest>
Then change the ZIP file extension to AAR in the explorer.
You can then specify the icons name from the senders side.
More details of the AAR anatomy here.
No need to change the manifest. This worked for me:
So you should be able to add your
icon(s) to
Assets/Plugins/Android/res/drawable/
and reference it name
Then, in the notification json, specify your icon. For example:
"notification": {
"title": "Title",
"body" : "First Notification",
"text" : "Text",
"icon" : "MyIcon"
}
Note: I used one of these icons.
Then change the ZIP file extension to AAR in the explorer. You can
then specify the icons name from the senders side. More details of the
AAR anatomy here.
If you just change the extension to aar, it won't compile.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Could not resolve all files for configuration ':unityLibrary:releaseCompileClasspath'.
> Failed to transform firebase_notification_icon-.aar (:firebase_notification_icon:) to match attributes {artifactType=android-classes-jar, org.gradle.status=integration, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: C:\...\.gradle\caches\transforms-2\files-2.1\ea6ac2b3d0993f0958d52cbbdfbd76ea\jetified-firebase_notification_icon.aar.
> entry
AAR-file must be created in Android Studio. Since it must contain a number of required files such as AndroidManifest.xml, classes.jar, etc.

Managing 4 application as a single application in android

I have 4 application namely 'A,B,C,D' and one controller application called 'M' i have only one launcher that will launch the 'M' application .In that 'M' application i have 4 buttons for launch that 'A,B,C,D' apps My problem is i need to Un install all four application when the user un install the 'M' application from the Device
Note : Deleting that four application must not ask for the user confirmation.
I have signed that all application under a same key store.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.demoapp.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="com.example.demoapp.MainActivitya"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.demoapp.MainActivityb"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.demoapp.MainActivityc"
android:label="#string/app_name" >
</activity>
i hope this is useful for you.
you don't put below code in other a,b,c,d activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I don't think you can do it with a straightforward solution on un-rooted devices.
A proposal, you can hide “A, B, C, D" by not assigning launch to them. Only "M" can start them by intents with special private action.