انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل در Startup (در برنامه نویسی اندروید)

مشکل در Startup (در برنامه نویسی اندروید)

#1
سلام
وقتی برنامه رو خودم اجرا می کنم مشکلی نداره و درست اجرا میشه ولی در استارت آپ خطای Unfortunately MyFirstApp has stopped میاد
می خوام ببینم مشکل از کدهای زیره یا نه؟manifest:

کد پی‌اچ‌پی:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    
package="com.example.myfirstapp"
    
android:versionCode="1"
    
android:versionName="1.0" >

    <
uses-sdk android:minSdkVersion="11" android:targetSdkVersion="21" />
    <
uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <
uses-permission android:name="android.permission.INTERNET"/>

    
    
    <
application
        android
:allowBackup="true"
        
android:icon="@drawable/ic_instagram"
        
android:label="@string/app_name"
        
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
        
            <
activity android:name=".MyActivity"
                
android:screenOrientation="portrait"
                
android:launchMode="singleTask" >
                    <
intent-filter>
                        <
action android:name="android.intent.action.MAIN" />
                        <
category android:name="android.intent.category.LAUNCHER" />
                    </
intent-filter>
            </
activity>
            
            <
service android:name=".MyService" android:icon="@drawable/icon" android:label="@string/service_name" >
                <
intent-filter>
                    <
action android:name="com.example.myfirstapp.MyService" />
                </
intent-filter>
            </
service
            
            <
receiver
                android
:name=".receiver.StartMyServiceAtBootReceiver"
                
android:label="StartMyServiceAtBootReceiver">
                    <
intent-filter>
                        <
action android:name="android.intent.action.BOOT_COMPLETED" />
                    </
intent-filter>
            </
receiver>
            
    </
application>
</
manifest

 این هم در کلاس MyActivity قرار دادم

کد پی‌اچ‌پی:
public class StartMyServiceAtBootReceiver extends BroadcastReceiver {

        @
Override
        
public void onReceive(Context contextIntent intent) {
            if (
Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                
Intent serviceIntent = new Intent(contextMyService.class);
                
context.startService(serviceIntent);
            }
        }

    } 
پاسخ

مشکل در Startup (در برنامه نویسی اندروید)

#2
حل شد
پاسخ
 سپاس شده توسط شماره مجازی امارات


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان