展会信息港展会大全

unable to start service Intent
来源:互联网   发布日期:2016-01-14 09:26:07   浏览:1697次  

导读://AndroidManifest.xml?xml version=1.0 encoding=utf-8?manifest xmlns:android=http://schemas.android.com/apk/res/android package=jzh.activity android:versionCode=1 ......

//AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="jzh.activity"

android:versionCode="1"

android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name" >

<activity

android:name=".Activity02"

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="itherActivity" >

</activity>

</application>

</manifest>

//Activity02

package jzh.activity;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

public class Activity02 extends Activity {

/** Called when the activity is first created. */

private Button myButton =null;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

myButton =(Button)findViewById(R.id.myButton);

myButton.setOnClickListener(new MyButtonListener());

}

class MyButtonListener implements OnClickListener{

public void onClick(View v) {

//生成一个INTENT对象

Intent intent = new Intent();

intent.setClass(Activity02.this,itherActivity.class);

Activity02.this.startService(intent);

}

}

}

//itherActivity

package jzh.activity;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

public class itherActivity extends Activity{

private TextView myTextView =null;

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.other);

myTextView = (TextView)findViewById(R.id.myTextView);

myTextView.setText(R.string.other);

}

}

//STRING.XML

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="hello">Hello World, Activity02!</string>

<string name="app_name">Activity_02</string>

<string name="other">OtherActivitythesecondpage</string>

</resources>

//MAIN.XML

...

//OTHER.XML

...

赞助本站

人工智能实验室

相关热词: service

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港