zoukankan      html  css  js  c++  java
  • 首先运行application的name相应的类或做activity中间name相应的类?

    今天找到该程序条目中找到以下两个条件name我写了一个测试程序,一般如以下:

    看mainfest.xml

    <application

            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:name="com.example.test1.app"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.test1.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>

        </application>

    k看app

    package com.example.test1;


    import android.app.Application;
    import android.os.Bundle;
    import android.util.Log;


    public class app extends Application{
    public void onCreate(){

    super.onCreate();
    Log.d("tt","application");
    }


    }


    看activity例如以下

    public class MainActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
              Log.d("tt","activity");
              new app();

    }

    最后我们来看日志文件就清楚了:

    10-28 15:40:54.915: D/tt(4116): application

    10-28 15:40:55.525: D/tt(4116): activity

    这里就是说application 的name相应了类是在程序安装时候就创建了

    然后我第二次打开例如以下:


    仅仅有一个信息

    android.app.Application
    Base class for those who need to maintain global application state. You can provide your own implementation by specifying its name in your AndroidManifest.xml's <application> tag, which will cause that class to be instantiated for you when the process for your application/package is created.
    Base class for those who need to maintain global application state. You can provide your own implementation by specifying its name in your AndroidManifest.xml's <application> tag, which will cause that class to be instantiated for you when the process for your application/package is created.

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    csrf
    cookies和session区别
    关于Processing开发应用及发布分享的一些经验分享
    C++调用动态链接库DLL的隐式链接和显式链接基本方法小结
    C++最基本调用静态库的方法小结
    C++最基本调用动态链接库dll方法的小结
    基于Potplayer类播放器或Action!类录屏软件调取摄像头方式的定时抓拍保存图像方法小结
    基于Openframeworks调取摄像头方式的定时抓拍保存图像方法小结
    DOS使用技巧整理 [典型案例分享]
    正则表达式使用技巧整理
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4819306.html
Copyright © 2011-2022 走看看