Our team has made this app which sends SOS with coordinates (latitudes,longitudes) to the family members. Basically what we are doing is accessing the contacts list, adding some into list to send the sms to. What we need is a technique to reduce the time spent is switching from one activity to another, thus making UI smooth. Thanks
-
2Add `overridePendingTransition(0,0);` before `setContentView` on your Activity's `onCreate` method – Pedro Oliveira Oct 16 '14 at 15:40
2 Answers
Switching between activities is generally smooth. If it is not smooth that can be due to some heavy operation on UI thread. Human eyes can detect delay more than 200ms. So you need to find out where you are spending more time in processing.
Android provide Strictmode feature for same
From android documentation
StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.
You can find more details here
Sample code
public void onCreate() {
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
}
super.onCreate();
}
In addition to that as suggested by Nadeem you can remove default activity transition also.

- 6,667
- 4
- 31
- 61
startActivity(new Intent(v.getContext(), newactivity.class));
overridePendingTransition(0, 0);
OR
You can create a style,
<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">@null</item>
</style>
and set it as theme for your activity in the manifest:
<activity android:name=".ui.ArticlesActivity" android:theme="@style/noAnimTheme">
</activity>
For full reference see this switching activities without animation

- 1
- 1

- 2,357
- 1
- 28
- 43