程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> 先執行application的name對應的類呢還是activity中的name對應的類?

先執行application的name對應的類呢還是activity中的name對應的類?

編輯:C++入門知識

先執行application的name對應的類呢還是activity中的name對應的類?


今天找程序入口發現了下面的情況有兩個name我就寫了個測試程序大致如下:

先看mainfest.xml

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:name="com.example.test1.app"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name="com.example.test1.MainActivity"
android:label="@string/app_name" >







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對應了類是在程序安裝時候就創建了

然後我第二次打開如下:

\

只有一個信息<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+YW5kcm9pZC5hcHAuQXBwbGljYXRpb248YnI+CkJhc2UgY2xhc3MgZm9yIHRob3NlIHdobyBuZWVkIHRvIG1haW50YWluIGdsb2JhbCBhcHBsaWNhdGlvbiBzdGF0ZS4gWW91IGNhbiBwcm92aWRlIHlvdXIgb3duIGltcGxlbWVudGF0aW9uIGJ5IHNwZWNpZnlpbmcgaXRzIG5hbWUgaW4geW91ciBBbmRyb2lkTWFuaWZlc3QueG1s"s 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 tag, which will cause that class to be instantiated for you when the process for your application/package is created.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved