Now I would like to make shortcut, so my code is
ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
Intent intent = new Intent();
Intent launchIntent = new Intent(this, ActivityToLaunch.class);
intent.putExtra( Intent.EXTRA_SHORTCUT_INTENT, launchIntent );
intent.putExtra( Intent.EXTRA_SHORTCUT_NAME, /*someNickname()*/"" );
intent.putExtra( Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon );
setResult(RESULT_OK, intent);
But I got this error message.
ActivityToLaunch cannot be resolved to a type
In stackoverflow, I saw many codes such as
Intent launchIntent = new Intent(this, ActivityToLaunch.class);
What’s the matter?
My project uses android sdk version 2.2, and imports
import android.app.Activity;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.os.Bundle;
My manifest.xml is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.mytest"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<activity android:name=".ShortCutActivity" android:label="@string/shortcut_label">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and apkname is and com.my.mytest.
Please help me.
Thanks.
Is
ActivityToLaunchactual name of your activity? Because according to your manifest what you need is probablyor