android中如何模拟QQ登录状态
来源:互联网 发布:淘宝达人的申请理由 编辑:程序博客网 时间:2024/05/01 20:07
程序如下:
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class A06Activity extends Activity {
private NotificationManager nm;
private String[] status;
private Spinner s;
private ArrayAdapter<String> aa;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
s=(Spinner)findViewById(R.id.s);
status=new String[]{"在线","离开"}; //以两个状态来模拟
aa=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,status);
aa.setDropDownViewResource(R.layout.my_spinner); //自定义下拉列表模式
s.setAdapter(aa); //将两个状态放置在Spinner中
s.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
if(status[arg2].equals("在线")){
setNotificationType(R.drawable.qq,"在线");
}
else{
setNotificationType(R.drawable.offine,"离开");
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
public void setNotificationType(int iconId,String s){
//创建新的Intent,作为单击Notification留言条时会运行的Activity
Intent i=new Intent(A06Activity.this,A06Activity_01.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//创建PendingIntent作为设置递延运行的Activity
PendingIntent pi=PendingIntent.getActivity(A06Activity.this, 0, i, 0);
//创建Notification,并添加相关参数
Notification n=new Notification();
n.icon=iconId; //设置留言图片
n.tickerText=s; //设置留言内容
n.defaults=Notification.DEFAULT_SOUND; //设置留言默认的声音
//设置Notification留言条的参数
n.setLatestEventInfo(A06Activity.this, "QQ登录状态", s, pi);
nm.notify(0, n); //以NotificationManager.notify()来发出Notification
}
}
//当用户单击Notification列表中的状态时,会启动这个程序,程序以一个Toast来告诉用户这是“模拟登录QQ的状态 的程序”
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
public class A06Activity_01 extends Activity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Toast.makeText(A06Activity_01.this, "这是模拟QQ登录状态的程序", Toast.LENGTH_LONG).show();
}
}
AndroidManifest.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.a06"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".A06Activity"
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=".A06Activity_01"
android:label="@string/str"
></activity>
</application>
</manifest>
- android中如何模拟QQ登录状态
- PHP模拟QQ登录
- 模拟QQ登录界面
- QQ邮箱模拟登录
- 模拟QQ登录页面
- 关于Android如何集成QQ登录
- 测试中如何模拟低网速状态
- 模拟qq微博登录
- python模拟登录qq邮箱
- 如何登录Tencent QQ
- android 实现qq登录
- Android QQ登录
- Android 调用QQ登录
- 【Android】集成QQ登录
- android QQ 登录
- Android之QQ登录
- Android集成QQ登录
- Android QQ登录
- 在Windows 7中利用Windows Media Center观看互联网视频
- MVC官方教程索引
- Install Eclipse SDK 4.2 (Juno) on Fedora
- jsp标签jsp:setProperty用法
- 19 使用缓冲区是否一定可以提高复制效率
- android中如何模拟QQ登录状态
- hdu 4312 Meeting point-2
- jBPM4的PVM解析
- 用内存映射文件在进程中共享数据
- 让数据库飞起来 10大DB2优化技巧
- 优化SQL Server数据库查询方法
- 如何在程序运行中动态改变对象属性在PropertyGrid可见性和只读属性
- 属性串行化
- Peas Malaysian show goes ahead 黑眼豆豆乐队马来西