Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application behaves two different ways when user chose open and done at the time of installation in android.so what is the resion?

Tags:

android

NOTE: PLEASE DO NOT TEST IT DIRECTLY DEVICE WITH ECLIPSE. PLEASE GENERATE .APK FILE FIRST LATER COPY THAT .APK INTO YOUR DEVICE MEMORY THEN INSTALL FROM THERE

Application flow

1)open Loading screen(appear 5 sec)----->open News title screen

2)from News screen when user click on back button i override

public void onBackPressed() {
        moveTaskToBack(true);
}

3)when user again open his application he directly open his news title screen

this is my requirement and i done this successfully when user chose case1 at the time of installation which is specified in following cases

I build apk then upload it to server. Then on my galaxy 2.2 I type in url in a browser and download apk. After its finished downloading I install it. When Install is finished I have two options

Case 1 :- Done

case 2 :- Open

when I press Open application open successfully first time. when i click on application again(Second time) it again open Loading screen.

But when I choose Done and later access it through Application menu it works ok! so this choice determines how app behaves later? why? how? I'm puzzled

now i am upload some simple sample code

Activity 1: HelloWorldActivity.java

this contain simple button named as "first screen"

package com.hb.Screens;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button tv=(Button) findViewById(R.id.btn);
        tv.setText("First screen");
        tv.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(new Intent(HelloWorldActivity.this, secondScreen.class));
                HelloWorldActivity.this.finish();
            }
        });
    }

}

Activity 2:secondScreen.java

This contain simple button named as "Second screen"

package com.hb.Screens;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

public class secondScreen extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        Button tv = (Button) findViewById(R.id.btn);
        tv.setText("Second screen");
    }

    @Override
    public void onBackPressed() {
        moveTaskToBack(true);
    }

    @Override
    protected void onResume() {
        super.onResume();

    }
}

This is my manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.hb.Screens"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="4" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloWorldActivity"

                  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=".secondScreen"></activity>
     </application>
</manifest>
like image 455
Govindarao Kondala Avatar asked Nov 14 '22 06:11

Govindarao Kondala


1 Answers

If you have declare more than one activity as a launcher activity then remove it. If you have two launcher activities in the manifest then it may issue. I had issue to crash when I have declared more than one activity as a launcher activity.

Open is the facility to directly open the application when it finish the installation.

Done is the option if you have no plan to open the application after installation.

like image 185
Dharmendra Avatar answered Nov 16 '22 02:11

Dharmendra