پاسخ ها ( 2 )

    2
    2020-05-15T01:30:00+03:30

    سلام

    ابتدا نیاز دارید تا دسترسی زیر رو به AndroidManifest اضافه کنید:

    AddManifestText(
    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
    <supports-screens android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="true"/>)
    SetApplicationAttribute(android:icon, "@drawable/icon")
    SetApplicationAttribute(android:label, "$LABEL$")
    'End of default text.
    
    

    سپس نیاز به ساخت یک ساب و تعریف چند متغیر دارید، کتابخانه Phone و Core را باید به برنامه اضافه کنید، که در نهایت کدهای اکتویتی به شکل زیر میشود:

    #Region  Project Attributes
        #FullScreen: False
        #IncludeTitle: True
        #ApplicationLabel: My App
        #VersionCode: 1
        #VersionName:
        #SupportedOrientations: unspecified
        #CanInstallToExternalStorage: False
        '#DebuggerForceStandardAssets: true
    #End Region
    
    #Region  Activity Attributes
        #FullScreen: False
        #IncludeTitle: True
    #End Region
    
    Sub Process_Globals
    End Sub
    
    Sub Globals
        Private CreateShortcut As Button
    End Sub
    
    Sub Activity_Create(FirstTime As Boolean)
        Activity.LoadLayout("myappmain")
    End Sub
    
    Sub Activity_Resume
    End Sub
    
    Sub Activity_Pause (UserClosed As Boolean)
    End Sub
    
    Sub CreateShortCut_Click
    
        Dim shortcutIntent As Intent
        shortcutIntent.Initialize("", "")
        shortcutIntent.SetComponent("My.App/.main") '<------change My.App for your own app file name here, like "My.Game", look into Tools, Build Configurations for your app's name
    
        Dim in As Intent
        in.Initialize("", "")
        in.PutExtra("duplicate",False)
        in.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
        in.PutExtra("android.intent.extra.shortcut.NAME", "My App") '<-----Type here the name of the shortcut, "My App" for "Your App"
        in.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "color01.png")) '<----your app image here, "color01.png" for "yourpic.png"
        in.Action = "com.android.launcher.action.INSTALL_SHORTCUT"
    
        Dim p As Phone
        p.SendBroadcastIntent(in)
        DoEvents
     
    End Sub

    منبع

    موفق باشید.

    بهترین پاسخ
    0
    2020-05-15T15:48:56+03:30

    سلام خداقوت
    ممنونم از پاسختون
    ولی برای من کار نکرد و ایکون برنامه پس از نصب به صفحه اصلی اضافه نشد

    🙁

     

      1
      2020-05-16T20:59:44+03:30

      دقت کنید که نام برنامه رو در Sub CreateShortCut_Click باید همنام با نام برنامه که در Build Configuration نوشتید، باشه …

ارسال یک پاسخ