2015-07-12 2 views
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 файле:

EDIT: это фактическая 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 запускается, уведомление говоря что разрешения приложения были отклонены или что-то подобное появится.

Независимо от того, делает оно или нет, дело в том, что приложение не запускается при запуске.

Интересно, почему ..

Кто-нибудь знает, почему? Благодарю.

+0

попытаться заменить android.intent.action.MAIN с com.tominocz.stonequestapp.MainActivity и андроида. intent.category.LAUNCHER с android.intent.category.DEFAULT, отправьте свой логарифм для многих советов –

+0

Ой, думаю, я знаю, что я знаю, в чем тут проблема. может быть в файле StartOnBoot.java. Мне нужно просто удалить инструкцию if при сканировании если s ystem завершил загрузку .. –

+0

StartOnBoot.java должен быть нормальным файлом класса тогда .. как нет расширяет материал ... –

ответ

0

Попробуйте это.

<?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="com.tominocz.stonequestapp.MAINACTIVITY" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".PlayerListActivity" 
      android:launchMode="singleTask" 
      android:screenOrientation="nosensor" 
      android:theme="@style/AppTheme" > 
      <intent-filter> 
       <action android:name="com.tominocz.stonequestapp.PLAYERLISTACTIVITY" /> 
       <action android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".SettingsActivity" 
      android:launchMode="singleTask" 
      android:screenOrientation="nosensor" 
      android:theme="@style/AppTheme" > 
      <intent-filter> 
       <action android:name="com.tominocz.stonequestapp.SETTINGSACTIVITY" /> 
       <action android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

Добавить это OnReceive()

Intent start = new Intent(getApplicationContext(), MainActivity.class); 
    startActivity(start); 

И убедитесь, что MainActivity продлить активность

Смежные вопросы