Android中初步认识HelloWorld(一)

本博客记录了每日的安卓学习笔记源码,并分享了对于生活、工作的独到见解,强调了在追求完美中寻找快乐的重要性。通过具体代码示例展示了Android应用的基本结构与生命周期管理,以及如何实现简单的拨打电话功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:
          今天是10月10日,又称十全十美日。
          其实,
          工作没有十全十美,尽心就好;
          生活没有十全十美,简单就好;
          朋友没有十全十美,真诚就好;
          爱人没有十全十美,真心就好;
          亲人没有十全十美,和睦就好;
          幸福没有十全十美,知足就好;
          人生没有十全十美,快乐就好!.
          所以,
          我决定从今天开始每天更新一篇安卓学习笔记源码。
package com.itarchy.demo;

import android.app.Activity;
import android.os.Bundle;

public class MyActivity extends Activity{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}
	

}

package com.itarchy.demo;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

public class HomeActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		System.out.println("onCreate");
		Log.d("TAG", "---HomeActivity--->onCreate");
		Log.i("Hello", "---HomeActivity--->onCreate");
		// Uri uri = Uri.parse("tel:13720012564");
		// Intent it = new Intent(Intent.ACTION_VIEW, uri);
		// it.putExtra("sms_body", "The SMS text");
		// it.setType("vnd.android-dir/mms-sms");
		// startActivity(it);
		
		Intent intent = new Intent();
		intent.setAction(Intent.ACTION_DIAL);
		//ACTION_DIAL   ACTION_CALL
		Uri uri = Uri.parse("tel:13720012564");
		intent.setData(uri);
		startActivity(intent);

		
		//startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com")));


	}

	@Override
	protected void onStart() {
		super.onStart();
		Log.d("TAG", "---HomeActivity--->onStart");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Log.d("TAG", "---HomeActivity--->onResume");
	}

	@Override
	protected void onPause() {
		super.onPause();
		Log.d("TAG", "---HomeActivity--->onPause");
	}

	@Override
	protected void onStop() {
		super.onStop();
		Log.d("TAG", "---HomeActivity--->onStop");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		Log.d("TAG", "---HomeActivity--->onDestroy");
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		Log.d("TAG", "---HomeActivity--->onRestart");
		
	}
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".HomeActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ni hao" />
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="center" />

</RelativeLayout>



package com.itarchy.demo;

import android.app.Activity;
import android.os.Bundle;

public class MyClass extends Activity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

}

package com.itarchy.demo;

import android.app.Activity;
import android.os.Bundle;

public class NewActivity extends Activity{
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	
	@Override
	protected void onStart() {
		super.onStart();
	}
	
	

}


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.itarchy.demo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/qq_ph"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name="com.itarchy.demo.MyActivity" >
        </activity>
        <activity android:name="com.itarchy.demo.HomeActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值