Title: android app crashes on launch when i try to declare an intent in kotlin
Tags: android;kotlin;android-intent;android-pendingintent
Question: please help

```val snoozeIntent = Intent(this, SnoozeReceiver181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16lass.java).apply {
        action = "ACTION_SNOOZE"
        putExtra("EXTRA_NOTIFICATION_ID", 0)
    }
```

i'm trying to follow the documentation here:
https://developer.android.com/training/notify-user/build-notification#Actions

my broadcast class:

```class SnoozeReceiver: BroadcastReceiver() {
    private val REQUEST_CODE = 0

    override fun onReceive(context: Context, intent: Intent) {
        val triggerTime = SystemClock.elapsedRealtime() + DateUtils.MINUTE_IN_MILLIS

        val notifyIntent = Intent(context, AlarmReceiver181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16lass.java)
        val notifyPendingIntent = PendingIntent.getBroadcast(
            context,
            REQUEST_CODE,
            notifyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT
        )
        val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
        AlarmManagerCompat.setExactAndAllowWhileIdle(
            alarmManager,
            AlarmManager.ELAPSED_REALTIME_WAKEUP,
            triggerTime,
            notifyPendingIntent
        )

        val notificationManager = ContextCompat.getSystemService(
            context,
            NotificationManager181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16lass.java
        ) as NotificationManager
        notificationManager.cancelAll()
    }

}
```

Android manifest :

```<receiver
                android:name=".receiver.SnoozeReceiver"
                android:enabled="true"
                android:exported="false"&gt;
            <intent-filter&gt;
                <action android:name="ACTION_SNOOZE"/&gt;
            </intent-filter&gt;
        </receiver&gt;
```

Comment: Thanks so much @Md.Asaduzzaman it worked but now it's happening with the next line of code which is 
```
val snoozePendingIntent: PendingIntent =
        PendingIntent.getBroadcast(this, 0, snoozeIntent, 0)
```
can you also tell ne the reason why is this happening i'm new to android environment

Comment: Are you initializing this variable outside of a method? If so, that's your problem. You need to initialize the variable after your `Activity` (or whatever) has been completely constructed (ie: after `onCreate()` has been called).

Comment: Use `Intent().apply` instead

Comment: From where you try to implement this? Please add more details of your implementation



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:02/23/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><kotlin><android-intent><android-pendingintent>', 'Title': 'android app crashes on launch when i try to declare an intent in kotlin', 'ViewCount': 120, 'id': 60360770, 'user_AboutMe': '', 'user_AccountId': 7985679.0, 'user_DisplayName': 'Akshit W.', 'user_Reputation': 69.0, 'user_Views': 32.0, 'user_id': 6025307.0}}