求一个android的联网的小项目,最好有技术文档的,借来看看下,自己做了个项目,loading跳转跳不过去了,期盼大牛过来看下
package com.le1web.fenghuang;
import java.io.File;
import com.le1web.fenghuang.config.config;
import com.le1web.fenghuang.data.data;
import com.le1web.fenghuang.server.getversion;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.VideoView;
public class loading extends Activity implements OnCompletionListener {
/** Called when the activity is first created. */
public VideoView vv;
public int s = 0;
public LinearLayout loading_mc;
public boolean b = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.loadings);
data.exitmodule(this);
data.activityList.add(this);
data.init(this);
int width = this.getWindow().getWindowManager().getDefaultDisplay().getWidth();
int height = this.getWindow().getWindowManager().getDefaultDisplay().getHeight();
loading_mc = (LinearLayout) findViewById(R.id.loading_mc);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
config.p_w = dm.widthPixels;
config.p_h = dm.heightPixels;
Toast.makeText(this, "SD状态:" + ExistSDCard(), 3).show();
if (ExistSDCard()) {
config.SDPATH = Environment.getExternalStorageDirectory() + "/";
} else {
config.SDPATH = getFilesDir().getParent() + "/";
}
// 创建主存储目录
try {
File dir = new File(config.SDPATH + "le1app/");
dir.mkdir();
if (isFileExist(config.SDPATH + "le1app/") == false) { // SD卡目录创建失败
config.SDPATH = getFilesDir().getParent() + "/";
File dir_ = new File(config.SDPATH + "le1app/");
dir_.mkdir();
}
String dirpath = config.SDPATH + "le1app/";
String str = "chmod" + dirpath + " " + "777" + "&& busybox chmod " + dirpath + " " + "777";
Runtime.getRuntime().exec(str);
} catch (Exception ex) {
Toast.makeText(this, "创建目录异常", 3).show();
}
Toast.makeText(this, "文件夹状态:" + config.SDPATH + "le1app/ =" +
isFileExist(config.SDPATH + "le1app/"), 3).show();
// 版本号
try {
config.version = getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
Log.i("version", config.version + "");
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
--------------->>从这边开始下面的好像就没执行到
// 检测版本号: appinfo/version.php
getversion gv = new getversion(handler_);
Thread t1 = new Thread(gv);
t1.start();
// 记录
send_info si = new send_info();
Thread t2 = new Thread(si);
t2.start();
}
// 判断SD卡上的文件夹是否存在
public boolean isFileExist(String fileName) {
File file = new File(fileName);
return file.exists();
}
// 检测sd卡
private boolean ExistSDCard() {
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
return true;
} else
return false;
}
public Handler handler_ = new Handler() {
public void handleMessage(Message msg) {
String str = (String) msg.obj;
if (str.indexOf("-1") == -1) {
showver((String) msg.obj);
} else {
startActivity(new Intent(loading.this, bookList.class));
}
}
};
public void showver(final String downfile) {
// 有新的版本了//
b = false;
Log.i("downfile", downfile);
new AlertDialog.Builder(this).setTitle("提示").setMessage("有新的版本了!是否马上升级?").setPositiveButton("马上升级", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Uri uri = Uri.parse(config.server + "appinfo/file/" + downfile);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
b = true;
}
}
).setNegativeButton("下次在说", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(loading.this, bookList.class));
b = true;
}
}).show();
}
public void onStart() {
super.onStart();
vv = new VideoView(this);
// vv.setVideoURI(Uri.parse("android.resource://com.le1web.app/" +
// R.raw.animation));
// vv.setOnCompletionListener(this);
// vv.setMinimumHeight(800);
// vv.start();
// loading_mc.addView(vv);
}
@Override
public void onCompletion(MediaPlayer arg0) {
vv.pause();
if (s == 0 && b == true) {
SharedPreferences sp = getSharedPreferences(config.soname,
MODE_WORLD_READABLE);
;
if (sp.getString("uid", "") != "")
{
startActivity(new Intent(loading.this, bookList.class));-->>这边
} else {
startActivity(new Intent(loading.this, bookList.class));-->>这边
}
s = 1;
}
overridePendingTransition(0, 0);
}
}