[Q] "UNINSTALL_SHORTCUT" does not work any more for android 4.0 (API 14 and above) - Android Q&A, Help & Troubleshooting

[Q] "UNINSTALL_SHORTCUT" does not work any more for android 4.0 (API 14 and above)
Hi,
The following code "UNINSTALL_SHORTCUT" works for
Android 2.3.3 (API 10) to Android 3.3 (API 13), but does not work any
more with Android 4.0 (API 14) or above.
The Toast message says it is removed, but actually it still exist and
the new one just place on top of the existing one. This creates
multiple shortcuts on top of each other.
Does anyone see the same issue I am seeing or there's other fix for
this with Android 4.0?
Thanks in advance for your help.
=================================
private void deleteShortCut(Context context) {
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName("com.example.androidapp",
"SampleIntent");
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.putExtra("someParameter", "HelloWorld");
Intent removeIntent = new Intent();
removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
shortcutIntent);
removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Shortcut
Name");
removeIntent.putExtra("duplicate", false);
removeIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
context.sendBroadcast(removeIntent);
}
private void addShortCut(Context context) {
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName("com.example.androidapp",
"SampleIntent");
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.putExtra("someParameter", "HelloWorld");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Shortcut Name");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context, R.drawable.icon));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(addIntent);
}
=======================================
AndroidManifest.xml...
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.example.addDeleteShortcut"
android:versionCode="8" android:versionName="1.0.0.1">
<uses-permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
<supports-screens
android:largeScreens="true"
android:anyDensity="true"
android:smallScreens="true"
android:resizeable="true"
android:normalScreens="true"
/>
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
<activity
android:name=".UIShortcuts"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".shortcutActivity"
android:taskAffinity="com.example.Change"
android:theme="@style/NoBackground"
android:excludeFromRecents="true" >
<intent-filter>
<action android:name="com.example.TOGGLE_SHORTCUT" /
>
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>

Hi there,
Did you mange to solve this issue with API 14 or above?
Nixu

Related

-Permission Denial: receiving Intent- with C2DM

Hi,
I want to use the C2DM, but I always get follwoing Error:
Code:
10-05 02:10:40.394: WARN/ActivityManager(11985): Permission Denial: receiving Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[mobile.app] (has extras) } to mobile.app requires mobile.app.permission.C2D_MESSAGE due to sender com.google.android.gsf (uid 10046)
Here is my Manifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mobile.app"
android:versionName="0.1"
android:versionCode="1">
<uses-sdk android:minSdkVersion="10" />
<!-- Only this application can receive the messages and registration result -->
<permission android:name="com.google.android.c2dm.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="mobile.app.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Send the registration id to the server -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<!-- Only C2DM servers can send messages for the app. If permission is not set - any other app can generate it -->
<receiver android:name=".C2DMReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<!-- Receive the actual message -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="mobile.app" />
</intent-filter>
<!-- Receive the registration id -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="mobile.app" />
</intent-filter>
</receiver>
</application>
</manifest>
Anyone an idea?
thanks!
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A

[Q] what is “BasicDream” in android ICS?

I read the Launcher source code which version is ICS. There is a RocketLauncher class which extends BasicDream. what is BasicDream? what can BasicDream do? I can find this line import android.support.v13.dreams.BasicDream;, but I can't find any information about it on Internet. Please give me some information to understand it. Thanks!
I found those code in launcher manifest.xml <activity android:name="com.android.launcher2.RocketLauncher" android:label="@string/dream_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DREAM" /> </intent-filter> </activity>
There is a new category android.intent.category.DREAM, what is it used to do? That RocketLauncher is an Activity?

[Q] ADW Theme - Help...

Alright so to start off i have eclipse, the android sdk, and all that other good stuff setup properly.
Now the problem is i keep getting an error in the androidmanifest.xml saying
<uses-sdk android:minSdkVersion="4"/>
The error message when clicked upon is, <uses-sdk> tag appears after <application> tag.
I have tried multiple versions of the sdk build including 2.2 (as the guide suggest) and changing the minimum sdk requirement but i always seem to run into this exact same problem. Any ideas? Oh and also im using this template
AnderWeb-ADW.Theme-Template-d8491c4
Heres the entire AndroidManifest.xml...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Red.Glow.Adw"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="internalOnly">
<application android:label="@string/theme_title" android:icon="@drawable/theme_icon">
<activity android:name=".main"
android:label="@string/theme_title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="org.adw.launcher.THEMES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="org.adw.launcher.icons.ACTION_PICK_ICON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="red.glow.adw.docks"
android:label="@string/theme_title"
android:icon="@drawable/theme_icon">
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
<provider android:name="red.glow.adw.docksProvider" android:authorities="red.glow.adw.docksProvider" />
</application>
<uses-sdk android:minSdkVersion="4"/>
</manifest>
Ehh figured it out.. AnderWeb's template build was throwing me up a ton of errors but kaydensigh's template works great.

[SOLVED][Debug Help] Empty/White Activity (invisible UI controls)

Hello! I generated a very simple 2 activities app using Google's Android Studio, and the target is an Android 8.1 phone. The problem is that the main activity doesn't show the edit box and buttons (that are obviously visible in the Design page). If I start my login activity (in the onCreate() function of the main activity), the login activity UI is visible and the main activity UI is still not visible. If I single step debug the app, the main activity UI seems present (as no error is encountered). They are just invisible. I compared the XML of both activities, and couldn't find a different setting that would fix this problem.
PS: I could't find a solution in Google search either.
PS: I added a space to break the URL links below.
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http: //schemas.android.com/apk/res/android"
package="com.example.test2">
<application
android:allowBackup="true"
android:allowTaskReparenting="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/AppTheme">
<activity
android:alwaysRetainTaskState="false"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:alwaysRetainTaskState="false"
android:label="@string/app_name"
android:name=".LoginActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.test2.MainActivity" />
</activity>
</application>
</manifest>
activity_main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http: //schemas.android.com/apk/res/android"
xmlns:app="http: //schemas.android.com/apk/res-auto"
xmlns:tools="http: //schemas.android.com/tools"
android:id="@+id/containerMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp"
android:visibility="visible"
tools:context=".MainActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="46dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/textName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/TextNameHint"
android:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:clickable="true"
android:enabled="true"
android:focusable="true"
android:longClickable="false"
android:onClick="buttonClick"
android:text="@string/Button"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>
MainActivity.java
Code:
package com.example.test2;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ToggleButton;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Thanks in advance!
[SOLVED] [Debug Help] Empty/White Activity (invisible UI controls)
Even though the design view seemed fine to me, including constraints and all, something was off to make the UI controls invisible. To try to isolate the problen, I decided to delete the controls one by one, and then I started to see something.
So, I made a different UI design. :cyclops:

Android 8.1 : broadcast receive does not work when I restart the smartphone

Hi,
I am designing an android application in java and I would like it to launch when the smartphone starts up I of course registered a BroadcastReceiver for the BOOT event of my phone as explained here but it does not work on Android 10 if not for info it worked on Android 4.1.
Can you help me please ?
Here is my code:
Manifest :
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.openclassrooms.fr.premierprojet">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".PremiereActivite">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".StartAppOnBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
</manifest>
Classe Main :
Code:
package com.openclassrooms.fr.premierprojet;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class PremiereActivite extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Classe Diffuseur :
Code:
package com.openclassrooms.fr.premierprojet;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class StartAppOnBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Intent i = new Intent(context, PremiereActivite.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
Cordially.

Categories

Resources