Re-add Cyanogenmod's CustomTile after it was manually removed - android

I'm toying with a very simple app that just adds a quick settings tile using Cyanogenmod CustomTile API.
Everything works (my app's code closely resembles the CM SDK sample app), except for a single scenario. The problem is, once I've manually removed the tile I can't find any way to add it back.
I've tapped "edit tiles" and deleted my app's tile. Now calls to CMStatusBarManager.publishTile don't seem to have any effect (I've surely tried to restart the app) and the only tiles listed for manual addition are the system ones. Uninstalling the app and re-installing it works, but I want to handle this scenario in somewhat more user-friendly fashion.
It would be best if I only could register the tile to be listed along the system ones in "edit tiles" mode, but I guess there's no API for this at the moment. Another acceptable solution is a way to re-add the tile (I'll just show a warning that tile was removed and a button to re-add it).
The question is specifically about CyanogenMod 12.1 and 13. Right now I don't care about any upcoming Android N stuff — I just want to make a user-level application specifically for CM-based ROMs of a certain phone have a feature and be on par with stock ROM.

Related

Black backgrounds are transparent on Lollipop until app is installed a second time

I'm having a bizarre transparency issue with my app on Android Lollipop (and only Android Lollipop).
Steps:
Uninstall any previous versions of my app.
Install the app.
Notice weird transparency on some fragments in my app (full-screen dialog, a fragment we slide in, our pull-to-refresh code).
Build a new binary with no code changes and install on the phone as an update.
Fragments all look fine.
Steps 1-3 I understand -- maybe some material theme is being applied inconsistently, or there's an issue with the custom themes we use in our app.
But I don't understand why re-deploying to the phone fixes the problem.
I'm seeing this on an unmodified Nexus 5 that got the Lollipop update over the air. I see the same issue on the Lollipop emulator.
I've tried changing our targetSdk from 19 to 21 and it did not help. minSdk remains at 15.
Has anyone seen an issue like this and can hopefully point me in a direction to debug?
Edit: Clearing data causes the transparency to return. Force-stopping the app and restarting it fixes the transparency issue. So I think cybersam is on the right track with his answer below -- there's some kind of issue in bootstrapping. But the fragments in question use #android/color:black and #color/my_app_black (= #FF000000) as their background colors, so I don't think the issue is in my app-specific code.
There is not enough information to say for sure what is going on, but I can see one scenario that can cause this. It may be totally unrelated to your situation, but here it is, anyway:
(1) You normally depend on persistent data (e.g., stored in shared preferences, DBs, files, etc.) to determine how to display your background, and have a bug where you: (a) look for the persistent data, (b) see it's not there and use an inappropriate default value (e.g., null) instead, and (c) go on to display strange backgrounds due to the bad default value.
(2) However, you also have special code that detects the missing persistent data and initializes it with appropriate values. But that special code has a bug in that it does not update your in-memory state to match the stored values.
With the above situation, during a fresh install (and as long as the app is not killed by the system and then re-started), you would continue to use the bad data and see the bad backgrounds. During a re-installation (where you did not uninstall the app first), the system would kill your app and then re-install it without deleting its persistent data. Therefore, on a re-installation, bug (1) would not be hit and you would see the expected backgrounds.
Not really an answer, but adding a values-v21 and changing my black color to #010101 works fine. I have no idea what the issue is. Seems like an obscure theme misuse or an obscure platform bug.

Adding new menu item to right-click (all platforms)

I have seen a lot of software and browser plugins do this. After installing them, they add some menu items to the system right click. Eg. On my PC, SVN added the item "SVN Checkout" to my right-click menu throughout.
On Android, you see Whatsapp adds itself to the Share menu across the entire system, so for every image you want to share, the option for Whatsapp also shows up. Similar stuff is done by Apps like Pocket, which adds the menu item "Save to Pocket"; so when you click on any article, you see "Save to Pocket" in the menu.
Question: How is this done? Is there a cross platform, generic way, or does this have to be done differently for every platform?
I need to provide this functionality to my users across Windows/Linux/Mac and Android/iOS. Any guidance on this is appreciated!
Update: Can this be done using only Java? That way, one solution will work on all platforms with Java
Thanks
No, there is no cross-platform way to do this.
In Windows, you edit the registry.
In Android, you can implement this in as number of different ways using the Android SDK.
Every platform has it's own APIs.
You also have a bit of a flawed mental model when you compare Android and Windows (or and mobile OS with any desktop OS). The features you mention for Android are built into an app running in the operating, while the contextual (right click) menu in Windows and OSX is a feature of the operating system itself.

How to enable/disable 3G/2G in Android SDK

I am just wondering how to enable/disable 3G/2G using the Android SDK and not just intenting to the 3G settings page. Thanks. Also is there a way to do the same thing, but with GPS. Thanks!
There is no exported to the SDK functionality to switch between 2G and 3G. For a given device you could probably figure out the private functionality, but it wouldn't work unless the app was signed with the system key.
You can disable the radios though, by turning on airplane mode.
And you might be able to make a shortcut to open the appropriate settings activity directly, instead of going through a few levels of menus to get there.
If you make your own build, you can presumably add the capability you really want, but that's likely not useful to anyone but yourself.
Edit: further detail - to understand how it works, look at the settings menu code (default version, a given device will differ):
http://android.git.kernel.org/?p=platform/packages/apps/Phone.git;a=blob;f=src/com/android/phone/Settings.java;hb=HEAD
Edit: AOSP is no longer served from kernel.org. A browsable mirror of
the current phone repository is at
https://github.com/android/platform_packages_apps_phone however due to
evolution of code organization there is no longer a Settings.java
there. One might either use git to reconstruct the version above from
this repository, or else try to figure out where the code has migrated
to in current releases.
You would need to find out the implementation specific set of NT_MODE_ constants you wish to toggle between. And you need to be able to write to secure settings, which requires being signed with the system key. Unless it's a custom build, you probably don't have access to that.
You cannot enable or disable any of these from an SDK application.

How to re-build the default "Launcher" application?

My goal is to modify the Launcher application and dynamically modify and change the theme.
I saw several 'home' apps at http://www.cyrket.com/p/android/com.stain46.taghome/. It looks like they took the default Home(Launcher) and modified it. How did they do that? What do I need to modify to achieve the same thing?
I have done this with the ICS launcher. You also need to do quite a number of code changes to get it to compile as a normal app because it uses a lot of private internal APIs (despite what Google may have implied). You also need to change the package name. There are two limitations I've found:
There's a filter called TableMaskFilter that isn't available to normal apps. I think this allows the app drawer to be semi-transparent, but I removed uses of it and it looks fine I think.
More critically, it appears there is no way to replicate the widget-adding experience because it requires a permission that only system apps can have. See this question.
Anyway, I put my source here. It compiles and works on the official Galaxy S2 4.0.3, but if you try to add widgets it will crash.
Note, when you're changing the package name, there are places that Eclipse's refactor doesn't notice (e.g. XML layouts). I recommend you do a global text search/replace instead.
The standard Launcher is open source so you can definitely grab it and modify it the way you want. For your app to be used as the Home Screen you will need to specify the correct Intent filter in your AndroidManifest.xml and the user will have to choose your app when they press the Home button. Why don't you grab that code, play with it and come back when you have more questions and more of an idea of what you want to change.
Here i found one stable version Launcher2
I have sharing that GitHub repo. HERE
WIKI of this project :
This project contains the code for the Launcher app that ships with Android Jelly Bean (API 16).
Some minor changes were required from this source code to remove the use of private APIs. These changes have been marked by "// AOSP Change"

[android]how can i create customize profile like meeting etc

i m new in android i want to create application that gives option for create new profile (like meeting,outdore etc),manage profile(not location base it's manually)
plz help me
If I understand you correctly, you want to quickly switch between several profiles that change certain settings like Wifi On/Off, mutes all sounds, etc. right?
If that's what you want then your best bet would be to not re-invent the wheel and - depending on what phone you have - to install a custom ROM like CyanogenMOD which already features profile management. This would void your warranty though.
Otherwise, you could possibly achieve this with either an Xposed module (will most likely only work if you have a Nexus device, since it requires a pure "AOSP" version of Android and Root permissions) or the app "Tasker" which also requires Root access.

Categories

Resources