1
我有這個在我的Manifest.xml文件:應用程序沒有啓動的啓動
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tominocz.stonequestapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="nosensor"
android:theme="@style/AppTheme" >
<receiver
android:name="com.tominocz.stonequestapp.StartOnBoot"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="nosensor" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PlayerListActivity"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
而且我有這個在我的StartOnBoot.java文件:
編輯: 這是實際StartOnBoot。 Java文件我有:
package com.tominocz.stonequestapp;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import com.tominocz.stonequestapp.config.Config;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@SuppressWarnings("deprecation")
@SuppressLint("SdCardPath")
public class StartOnBoot extends BroadcastReceiver {
public static String Latest;
public static String previous;
@Override
public void onReceive(final Context context, final Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
if (new File("/data/data/com.tominocz.stonequestapp/app.properties").exists()) {
Config.load();
if (MainActivity.StartOnBoot = true) {
getLatestVersion(context);
if (MainActivity.EnableNotifications = true) {
triggerUpdateNotification(context, "New version " + Latest + " released!");
}
}
}
}
}
public static void getLatestVersion(Context ctx) {
try {
String myUri = "http://www.stonequest.de/version.php";
HttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet(myUri);
HttpResponse response = httpClient.execute(get);
String ver = EntityUtils.toString(response.getEntity(), "UTF-8");
if (ver != null) {
Latest = ver;
if (MainActivity.EnableNotifications = true) {
if (previous != Latest) {
triggerUpdateNotification(ctx, "New version " + Latest + " released!");
}
}
}
} catch (Exception e) {
}
}
public static void loadLastVersion() {
try {
FileInputStream fis = new FileInputStream(new File("/data/data/com.tominocz.stonequestapp/Last.ver"));
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
previous = br.readLine();
fis.close();
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void triggerUpdateNotification(Context ctx, String s) {
CharSequence title = "StoneQuest just got updated!";
CharSequence message = s;
NotificationManager notificationManager;
notificationManager = (NotificationManager) ctx.getSystemService("notification");
Notification notification;
notification = new Notification(com.tominocz.stonequestapp.R.drawable.ic_launcher, "New version released!",
System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, null, 0);
notification.setLatestEventInfo(ctx, title, message, pendingIntent);
notificationManager.notify(1010, notification);
}
}
我不知道如果我的應用程序這樣做,但每當Android設備啓動時,通知說該應用程序的權限被拒絕或類似的東西會顯示出來..
無論如果它,或不,它的問題是,應用程序不會啓動時啓動。
我想知道爲什麼..
有人知道爲什麼嗎?謝謝。
嘗試com.tominocz.stonequestapp.MainActivity和Android更換android.intent.action.MAIN。 intent.category.LAUNCHER與android.intent.category.DEFAULT,發佈您的logcat的許多意見 –
哦,等待我想我知道這裏有什麼問題.. 也許在StartOnBoot.java文件我應該刪除if語句與掃描因爲如果s ystem已經完成引導.. –
StartOnBoot.java應該是正常的類文件然後.. 像沒有擴展的東西... –