Issue with Application Packaging in Kotlin - android

I have an app I built, deployed and is being tested with Google Developer Tester Option. My app(s) i have been developing has a wierd issue I can not put my finger on.
The App is a simple Note Taking App. So there is not a lot of code. I done my main activity only has about 60 lines of code. Everything else is composed of classes.
When I test my app on my cellphone. There is a time delay of 5 seconds that a white screen shows while launching. Then it goes to the app.
I would usually put a splash screen. And its seamless in loading. Without the splash screen with normal code it shows the white screen for 5 seconds.
My question is, am I doing something or wrong or is this something with the transition of .apk to .aab when packaging?
I have read articles of people saying its a bug withing Android itself. I have no warnings or errors within the app.
This has me puzzled and any advice would be helpful.
Here is a screenshot of the start up process.
Then this happens for 5 seconds then the main app shows
Any help is appreciated.

Ok after some test coding I finally solved the issue. To have the White Screen not appear you can create a splash screen or just a theme.
Theme should be set as follows
<style name="Theme.SplashScreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowDisablePreview">true</item>
</style>
Then in your SplashScreen.kt you can add the following
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}, 2000)
Then in your Manifest you need add the following:
<activity
android:name=".SplashScreen"
android:exported="true"
android:theme="#style/Theme.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
</activity>
This cuts the launch time with the Splash Screen to whatever your delay is set at.

Your application can't launch instantly, the time it takes to launch an application depends on several hardware factors. So the launch time is different from one smartphone to another
https://developer.android.com/topic/performance/vitals/launch-time

Related

App installed but not appearing

I am developing an Android app. At first everything was going smooth, but after some time, the app started to disappear (more accurate not appear) after a successful installation on a real android device. After installing it, the open button is deactivated (I can only click done) and I cannot find it on the menu, but checking with root uninstaller, it appears that the app is really installed.
On the emulator, it installs ok but the installed app doesn't show the correct icon, while prior to this error it wasn't doing so.
I forced the removal of some permissions # Manifest, because I only need (and the app was running with it only) internet access (web view). I tried removing that but it is just the same.
This change came when I introduced a splash screen which loads after the webview if it's the first time ==> MainActivity: If it's first time { setContentView with splash layout. Eventually, after the 3 slides, button onClick which changes to webview activity (class)(1) } else { setContentView with webview layout(2) }
(1) and (2) perform the same tasks, (2) inside a method in MainActivity and (1) in the onCreate of the WebView class.
I know for a fact that it is a better way to do this. Any help on how to do perform this task in a better way appreciated, and also how to get rid of the "installed but invisible" thing.
In your manifest ensure that your intent filter has the category <category android:name="android.intent.category.LAUNCHER" />
<activity
android:name=".activity.SpashScreenActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

SKMaps, Android landscape orientation issue

I am using SKMaps (Skobbler) to develop an Android app in Eclipse.
I have an application which displays a map, has 2 buttons, can find routes to a point on the screen I tap on and initiate the navigation the SDK provides.
My problem is when I change the orientation of the device the app just closes. It does not give me any error message so I cannot identify the source of the issue.
The demo application provided handles the orientation of the device easily. I noticed that when I turn it around in the LogCat a message is displayed saying:
05-09 12:22:37.560: D/SKMaps(7866): MapRenderer----onSurfaceChanged width = 720 height= 1134
My application simply closes with the last message being:
05-09 12:22:37.745: D/SKMaps(7866): SKCurrentPositionProvider----stopped receiving position updates
I cannot find where in the demo application the code to handle orientation is. Does anyone have any idea where I could be going wrong.
ps. I have declared in my Manifesto my activity as:
<activity
android:name="com.aatana.mymapproject.MyActivity"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the demo project, the MapActivity has overriden its onDestroy:
#Override
protected void onDestroy() {
super.onDestroy();
currentPositionProvider.stopLocationUpdates();
SKMaps.getInstance().destroySKMaps();
android.os.Process.killProcess(android.os.Process.myPid());
}
You need to delete the line that kills the process:
android.os.Process.killProcess(android.os.Process.myPid());

How could I set an activity to be the one to be resumed (by multitask)

I am experiencing a little pain on Android. I have two activities, one is a Splash Screen, launched when you click on the app icon, and an other one which can wake up when a specific event occurred (a NFC event, but it is not the problem).
There is the declaration in the manifest :
<activity android:label="#string/general.appName" android:name=".activity.SplashActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:excludeFromRecents="true" android:label="#string/general.appName" android:name=".EventReceiver" android:noHistory="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.nfc.action.TRANSACTION_DETECTED">
</action>
<category android:name="android.intent.category.DEFAULT">
</category>
<data android:host="secure" android:path="/aXXXXX" android:port="0" android:scheme="nfc"/>
</intent-filter>
</activity>
All works fine, it means that the EventReceiver is launched when it received a specific event, the Splash Screen is functional etc...
But, when the application is launched by an event, so it is the EventReceiver which is launched first. If I pause the app by clicking on the home button of the phone, and by long clicking on it again, it makes appear the multitask table, with all the recent opened apps. There, is I click on my application, it resumed the application on the EventReceiver, just like if an event had occurred. So do you know a way to resume an application on one selected activity only (in my case the SplashScreen).
Or do you know a way to recognize that the application was resumed by a multitask function ? (I could open the good activity at the onCreate of my EventReceiver too if I get this information).
For the moment, the only solution I found is to put a android:excludeFromRecents="true" flag on my EventReceiver activity. This will result that the application will not appear in the multitask table if the application was launched by an event. But this is a little bit tricky and I do not like that very much.
Do you have any ideas ?
Thank you very much beforehand for your answers ! (and sorry for my scholar English ^^)
If you really have to detect when the application is lauched from the "recents" you can use intent flags.
if (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) {
// Lauched from recent apps.
}
Do NOT use a splash screen. It only slows down your app experience and has no value what so ever.
In addition... Android apps are a lose set of activities... There is no concrete entry point that would need a splash screen.
That said... the app switcher returns you to the previously active activity. In your case the .EventReceiver. You could change your structure by using a second activity that shows your ui so that the EventReceiver lets you forward to that.
Correct me if i am mistaken... But can't you intercept the nfc event with an receiver? From there you should open your ui activity.

How to implement an app without activity? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Start android application without activity
I want to do a download tool for other apps. It would always run in background. All code in service. So no need for a UI. How do I do this?
You can still have an Activity just don't declare an intent-filter in your manifest, that way the user can never start your app from the menu and therefore never see the Activity unless you choose to show it. Going further you could make the Activity theme Transparent as well so that if it is brought to the front it doesn't show anything.
The kind of examples to look at would be a Live Wallpaper app.
http://developer.android.com/resources/samples/CubeLiveWallpaper/index.html
^ Ignore the actually wallpaper bits but notice that the app doesn't have an Activity
You can create a BroadcastReceiver that will start your Service and remove the Activity from the Manifest file.
<activity android:name=".StarterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The action MAIN and category LAUNCHER start the application, so remove <intent-filter> of StarterActivity from the <application>. Then your application will not visible into the applications list.

Launcher label randomly changes to activity label

I have a requirement that the title bar label on my launcher activity be different from the actual launcher label. This seems to work fine in the general case, however, I have a confirmed report from a user that their launcher label has changed over time to be the activity label. Here's an example:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/activity_title"
android:name="MyActivity" >
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Upon initial install, everything is correct. The launcher label shows up as the app_name string. When you launch the app the activity label is the activity_title string. However at some point the user opens up their app list and instead of seeing the app_name string for my app, they see the activity_title string.
They have installed multiple times and this seems to happen every time. Has anyone else seen this behavior and know of a way to resolve it?
EDIT:
After some more testing I figured out how to repro this every time with the manifest given above. If I install the app, then put a shortcut on the home screen and restart the emulator or device, then when it comes back up the shortcut has been renamed. The app in the app list is still correctly named. Weird stuff.

Categories

Resources