Smartwatches anyone? Windows.Phone.Notification.Management.AccessoryMan ager? - Windows Phone 8 Q&A, Help & Troubleshooting

So now with GDR1 we have all the API for smartwatches, but MS decided to block this API from regular developers. Only for OEMs.
Still is there any way I can use methods from this class? When I'm trying I always get System.UnauthorizedAccessException exception.
Any ideas? Should I add some compatibility declarations to the manifest?
try
{
AccessoryManager.GetApps();
}
catch (Exception ex)
{
MessageDialog d = new MessageDialog(ex.ToString(),"Exception ");
d.ShowAsync();
}

I have not had experience with the WP8.1/WP8.1 Update 1 yet but it could be related to how you have to ask the user for permission in the new API. It looks like the process is not straight forward but I would research that.

How to access to that libraries
I just want to ask, how did you access to that libraries, i already installed GDR1 update, but I cant access to that libraries.
Thanks

as anyone got the access to this api?? how??

Related

File Commands

Hi, how would u go about incoporating file commands such as delete into and android app in eclipse which i am using ?
Thanks
For manipulating files, you should look at java.io.File
i.e.
File file = new File("path");
file.delete();
Hey, thanks for that i tried it..it works for files but for deleting folders that are not empty it doesnt work ? ne way to work around that ?
Thanks Again For Your Quick Reply
I used this in my Audio Hack app and it worked nicely
Code:
Process process = null;
try {
process = Runtime.getRuntime().exec("su");
} catch (IOException e1) {
e1.printStackTrace();
}
DataOutputStream os = new DataOutputStream(process.getOutputStream());
try {
os.writeBytes("busybox rm -r blah/blah/blah \n");
} catch (IOException e) {
e.printStackTrace();
}
try {
os.writeBytes("exit\n");
} catch (IOException e) {
e.printStackTrace();
}
try {
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
this just runs any busybox command as root so you can do whatever you want.
it seems to only work for me with busybox at the start though, meaning anyone using it must have busybox.
hope this answers your question
Hmmm....nice script u have there...so im tryin to make a script for my app where it would go into a directory..get the filenames....n substitute that into the filename.delete() command....can neone help ?
Also on most command prompt/shells....when u do delete folder/*.* it deletes everything in tht folder...no substitute for android ?
You need to use caution when using that approach since;
1) it requires root (at least his example does),
*2*) it is dependent on what commands are available on the particular system. You can't rely on anything here.
The workaround for deleting non-empty directories is to first delete the contents in order to MAKE them empty.
It is fairly simple to write a recursive delete function;
void recursiveDelete(String path){
File file = new File(path);
if (!file.delete() && file.isDirectory()){
String[] filelist = file.list();
for (int i=0; i<filelist.length; i++) recursiveDelete(filelist);
file.delete();
}
}
I don't know what the paths that are returned by file.list() look like... there is another function "isAbsolute()" to check if it is a relative or absolute path returned... if it is a relative path, then you want to do your recursiveDelete on path+"/"+filelist.
Note: you could also take this approach, which is probably a little more clean;
void recursiveDelete(File file){
if (!file.delete() && file.isDirectory()){
File[] filelist = file.listFiles();
for (int i=0; i<filelist.length; i++) recursiveDelete(filelist);
file.delete();
}
}
This approach solves the whole absolute/relative path question. You just have to remember to
recursiveDelete(new File("path"));
Instead of:
recursiveDelete("path");
Daneshm90 said:
Hmmm....nice script u have there...so im tryin to make a script for my app where it would go into a directory..get the filenames....n substitute that into the filename.delete() command....can neone help ?
Also on most command prompt/shells....when u do delete folder/*.* it deletes everything in tht folder...no substitute for android ?
Click to expand...
Click to collapse
Actually, what he is doing is not at all scripted... he is running a SHELL COMMAND.

[GUIDE]Migrating from Eclipse to Android Studio

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
On Google I/O 2013, Google has launched new IDE based on IntelliJ IDEA, called Android Studio. I'm really interested in Android Studio, given that I usually using Eclipse in developing Android application. I find that this IDE is really good (or should I say awesome!). But some of my friends said that they're having difficulties in using Android Studio, and prefer the 'good but old' Eclipse. Yes, Eclipse is good, but Google is more supporting the Android Studio. So with this articles, I want to share my experiences in migrating from Eclipse to Android Studio. I also included Google's official guide from d.android.com/
Let's start with pros and cons of Android Studio:
PROS:
- Better UI in designing and coding
- ProGuard and app-signing capabilities.
- Gradle-based build support (For you that has already get used to it)
CONS:
- Hard to manage multiple projects. (For example: to delete a project you have to delete from the explorer)
- Gradle-based build support (For you that's not get used to it)
- Still in EAP (Early Access Preview)
If you have something to say about PROS-&-CONS, I'm glad to hear from you.
Now move along to installing Android Studio. It's very easy.
First of all, go to http://developer.android.com/sdk/installing/studio.html and download the installer.
Windows:
- Launch the downloaded EXE file, android-studio-bundle-<version>.exe.
- Follow the setup wizard to install Android Studio.
- Known issue: On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location. Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.
Mac OS X:
- Open the downloaded DMG file, android-studio-bundle-<version>.dmg.
- Drag and drop Android Studio into the Applications folder.
- Known issue: Depending on your security settings, when you attempt to open Android Studio, you might see a warning that says the package is damaged and should be moved to the trash. If this happens, go to System Preferences > Security & Privacy and under Allow applications downloaded from, select Anywhere. Then open Android Studio again.
Linux:
- Unpack the downloaded Tar file, android-studio-bundle-<version>.tgz, into an appropriate location for your applications.
- To launch Android Studio, navigate to the android-studio/bin/ directory in a terminal and execute studio.sh.
- You may want to add android-studio/bin/ to your PATH environmental variable so that you can start Android Studio from any directory.
After you installed Android Studio, let your journey begin. But first, you must remember that Android Studio is still in EAP, so there will be many bugs/glitches/errors/whatever-you-call-it that can be annoying. But if you patient enough, you will find it very fun.
How to create project?
It's easy! Just use File -> New Project...
Or, if it's your first time using Android Studio, you will be welcomed with options to "Create New project"
Exploring your projects
File system is quite different with Eclipse. Considering that your android apps will be Gradle-based. So you just have to modify everything inside main project folder (See picture, file under "DMap" is main project folder). Unless you're an expert in Gradle and Intellij.
After you get used to the UI and layout, you can start coding & designing your app.
Designing Layout using Android Studio is Better?
Yes! You can see pictures below that you have 2 options to design layout. First by typing it directly through "Text" mode, or "Drag-and-drop" design. Both of them enable you to preview your design. Just have a 15-minutes experiments with your preview, and you will feel the power!
Let me give you some examples:
Design with "Text" mode
Design with "Drag and Drop" mode
How to include support library?
Another beautiful thing that announced in Google I/O 2013 is ActionBar Compat. I'm waiting it for a long time, because using "Sherlock ActionBar" is a little bit complicated. And now it's released. Download it with your SDK Manager.
Then include it in your project. How? Because this is Gradle-based, it's quite simple. Open "build.gradle" in your main project folder.
For Android-Support v4:
- It's automatically included when you created new project. But if not, use second step.
- Add this line:
Code:
dependencies {
...
compile "com.android.support:support-v4:18.0.+"
}
For Android-Support v7:
- Add this line:
Code:
dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+"
}
How tot test your app?
Just like Eclipse, Android Studio support 2 way of testing. By using AVD (Android Virtual Devices) or by real devices. To edit configurations, go to "Run" -> "Edit Configurations". I recommend you to choose "Target Device" -> "Show chooser dialog", to give you more freedom in testing.
For AVD:
- You have to create at least one AVD. To create AVD, go to "Tools" -> "Android" -> "AVD Manager"
- In the chooser dialog, select AVD, and choose your devices.
For Real Device:
- You have to enable USB Debugging in your devices! Enable it, then go forward.
- Connect it through USB. In chooser dialog, you will see your device there.
Known issue: Sometimes the driver is not right. You should use Google USB Driver for testing app in Android. Or sometime, your device won't be detected if it's in sleep/locked mode.
How to generate a signed APK?
This is also easy! Android Studio is provided with App-signing capability so you don't have to open up your keytool or do somewhat-complicated task.
Here's some steps:
- Go to "Build" -> "Generate Signed APK..."
- Click "Create new..."
- To make a new keystore, just put a non-exist keystore in "Key store path:" (The folder MUST exist, while the file MUST NOT exist). And other details.
- It will automatically completed our last dialog in keystore. Just click "Next"
- And "Finish"
TIPS & TRICKS
If you want to change to Darcula Look and Feel, (in Windows) just press: "Ctrl + ~" -> "Switch Look and Feel" -> "Darcula".
This look and feel is very interesting, and I like it so much.
End of articles
It's easy doesn't it? There will be many improvements in the future that I don't know. But let's waiting for it. If you have any suggestions, questions, or even critics, just ask me. And also if you find it helpful, please click "Thanks" or "Donate". I will appreciate it very much.
Also check this official video from Google I/O 2013. About what's new in Android Studio
Multiple Projects
I currently have 8 active projects open in eclipse and during a single day I will work on at least 2-3 of them.
Does anyone know if android-studio will support this?
From what I have seen so far, it will only allow 1 project to be open at a time, this would mean have 4/5 android studios open at once just so that I can switch between projects.
Andy.
p.s. another question is : Can we use eclipse keystores for signing apps? if not what do we do about existing applications?
The thing that kept me off this was that it was impossible to correctly import an Eclipse project, when I tried it... I might give it a try by your instructions later.
Hi Andy,
Android Studio will separate your projects into multiple windows. But not multiple instances. So don't worry it will not consume your memory excessively.
And based on my experiences, Java keystore will be saved as (.keystore) file. So yes, even though you're using Eclipse or Android Studio both of them are the same. Just locate your keystore file, and "Choose existing...".
aspellclark said:
I currently have 8 active projects open in eclipse and during a single day I will work on at least 2-3 of them.
Does anyone know if android-studio will support this?
From what I have seen so far, it will only allow 1 project to be open at a time, this would mean have 4/5 android studios open at once just so that I can switch between projects.
Andy.
p.s. another question is : Can we use eclipse keystores for signing apps? if not what do we do about existing applications?
Click to expand...
Click to collapse
d.android.com has provided a useful solution for your problems, I think. Try this tips for export/import android projects from Eclipse to Android Studio. http://developer.android.com/sdk/installing/migrate.html
bassie1995 said:
The thing that kept me off this was that it was impossible to correctly import an Eclipse project, when I tried it... I might give it a try by your instructions later.
Click to expand...
Click to collapse
JoshieGeek said:
d.android.com has provided a useful solution for your problems, I think. Try this tips for export/import android projects from Eclipse to Android Studio. http://developer.android.com/sdk/installing/migrate.html
Click to expand...
Click to collapse
This way of working was not correctly working for me...
Have you checked that you do it right? For example: Have you export it from Eclipse first, then import it from Android Studio? And not import it directly from Android Studio?
Or do you have any specific screenshot for logs / things that can give me some clues?
bassie1995 said:
This way of working was not correctly working for me...
Click to expand...
Click to collapse
JoshieGeek said:
Have you checked that you do it right? For example: Have you export it from Eclipse first, then import it from Android Studio? And not import it directly from Android Studio?
Or do you have any specific screenshot for logs / things that can give me some clues?
Click to expand...
Click to collapse
I followed the steps, but long ago. I'm going to try again soonish.
Sent from my GT-I9300 using Tapatalk 4
Could someone give me a little guidance?
i checked that path and there isnt even a config folder.
Never mind, figured it out myself.
Has to make it run as administrator
Sent from my Galaxy Nexus
That's why if I'm using windows 7 (or above), I will not install some development-related programs to C partition. But another, it will be much more flexible to edit and something like that. By the way, you do a good job to solve your problems by yourself. Experimenting the problems is a good way to learn.
:good:
Garridon said:
Never mind, figured it out myself.
Has to make it run as administrator
Sent from my Galaxy Nexus
Click to expand...
Click to collapse
JoshieGeek said:
For Android-Support v4:
- It's automatically included when you created new project. But if not, use second step.
- Add this line:
Code:
dependencies {
...
compile "com.android.support:support-v4:18.0.+"
}
For Android-Support v7:
- Add this line:
Code:
dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+"
}
Click to expand...
Click to collapse
Thank you !
I think you mean "Android-AppCompat v7" not "Android-Support v7"
BTW when to use support-v4 vs appcompat-v7 ? What's the difference? Should I use both?
The difference is that appcompat-v7 will cover many more support libraries (for example: ActionBar compat). But your minimum version of App will be 7. So I recommend you to use appcompat-v7 than support-v4. Because there're not so many users that still using < v7.
From my experiences after I declare that dependencies, I got android support v4 and android v7. But still the minimum version MUST 7.
Have any questions? Feel free to ask me, I would be glad to help.
ceefour said:
Thank you !
I think you mean "Android-AppCompat v7" not "Android-Support v7"
BTW when to use support-v4 vs appcompat-v7 ? What's the difference? Should I use both?
Click to expand...
Click to collapse
JoshieGeek said:
The difference is that appcompat-v7 will cover many more support libraries (for example: ActionBar compat). But your minimum version of App will be 7. So I recommend you to use appcompat-v7 than support-v4. Because there're not so many users that still using < v7.
From my experiences after I declare that dependencies, I got android support v4 and android v7. But still the minimum version MUST 7.
Have any questions? Feel free to ask me, I would be glad to help.
Click to expand...
Click to collapse
Thanks Joshie! So appcompat-v7 it is...
So ActionBar is now provided by Google? So long Sherlock (it's still very nice though! yet I'm happy Google finally implements it too)
Yupz. And also implementation of Google's ActionBarCompat is very easy. So I prefer Google's to Sherlock..
But yeah, Sherlock is a good alternatives when Google has not even been releasing it.
Sent from my Nexus 4 using xda app-developers app
JoshieGeek said:
Yupz. And also implementation of Google's ActionBarCompat is very easy. So I prefer Google's to Sherlock..
But yeah, Sherlock is a good alternatives when Google has not even been releasing it.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
I switched to the Google one, too. However, there is this annoying bug: http://code.google.com/p/android/issues/detail?id=58321
And it does not provide a PreferenceActivity with the ActionBar.
Waiting for the next version...
Yupz.. Wait for the next version... It's quite a small bugs, and they promise will fix it in next release..
nikwen said:
I switched to the Google one, too. However, there is this annoying bug: http://code.google.com/p/android/issues/detail?id=58321
And it does not provide a PreferenceActivity with the ActionBar.
Waiting for the next version...
Click to expand...
Click to collapse
Sent from my Nexus 4 using xda app-developers app
JoshieGeek said:
Yupz.. Wait for the next version... It's quite a small bugs, and they promise will fix it in next release..
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Well, if you want to implement multi-selection with it, it won't work.
However, a fixed version can be found here: https://github.com/CyberEagle/SupportLibraryV7AppCompatPatched
I'll use that till they publish the new version.
Starter choice : Eclipse or Android Studio?
Hi,
I'm currently an Enterprise Java developer and want to start building some apps in mobile space. As a new mobile developer, which one should I get start with now; Eclipse or Android Studio?
Regards

[Q] who to moderate back key press in WP8.1

Hi every one
In WP8 we could use
Protected Override Void OnbackKeyPress(....e)
{
}
Now I didn't find such thing in windows Phone 8.1 ! Can anyone help me with this ?
and my other Q is : where is the messagebox.show ? and also Isolated Storage ?!
Now I think get an absolutely Noooob again
ngame said:
Hi every one
In WP8 we could use
Protected Override Void OnbackKeyPress(....e)
{
}
Now I didn't find such thing in windows Phone 8.1 ! Can anyone help me with this ?
and my other Q is : where is the messagebox.show ? and also Isolated Storage ?!
Now I think get an absolutely Noooob again
Click to expand...
Click to collapse
Hi,
instead of overriding OnbackKeyPress you have to register the event
...
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
...
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
// your code
e.Handled = true; // if you wanna prevent that the "standard"-eventhandler is called and your app getting closed
}
Best,
ElStoney said:
Hi,
instead of overriding OnbackKeyPress you have to register the event
...
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
...
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
// your code
e.Handled = true; // if you wanna prevent that the "standard"-eventhandler is called and your app getting closed
}
Best,
Click to expand...
Click to collapse
Thanks.
And what about isolated storage?
I can't use them any more and power tools ran out
Look for StorageFile and StorageFolder:
http://msdn.microsoft.com/de-de/library/windows/apps/windows.storage.aspx
And here is a Storage Helper class from Jerry Nixon that is useful: http://codepaste.net/gtu5mq

"Unfortunately Has Stopped" Only in Release Version

I am getting an "Unfortunately Has Stopped" message in my release version that does not occur in the debug version. This happens both on my S4 mini and on the Samsung RTL devices. The debug version works on all of these devices plus on the Genymotion emulators. The error occurs using Jsoup when i tap my menu choice which activates Jsoup.connect.
I determined that the problem is caused by ProGuard, by following a suggestion to disable ProGuard. The program runs if i change minifyEnabled to false or if i simply delete the two lines ...
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
Now i do not know what to do next. I do not want to post a bunch of code etc since i do not know what is needed. Also i do not know how to run the release APK with debugging or how to get a stack trace or other debugging information from a release build.
BTW, every line of my build.gradle file is haunted by the "cannot be applied to '(groovy.lang.Closure)'" warnings, but my research tells me that this a harmless Android Studio bug with no reliable workaround and would be unrelated.
I have a feeling that this is a common problem with a well known solution but i have not been able to find much discussion on various forums. Any guidance much appreciated,
Mick

[Newbie] Correct way to start some App when Android started

I finding a correct way to start some app when started Android or restared
I have something like
Code:
public void startSomeApp() {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("xxx.xxx.xxx");
if (launchIntent != null) {
context.startActivity(launchIntent);
}
}
But was wonder a correct way where should I put?
I try to push to
Code:
public void initZygote(StartupParam startupParam) throws Throwable {
startSomeApp();
}
But problem with context, any trick please?
1001z said:
I finding a correct way to start some app when started Android or restared
I have something like
But was wonder a correct way where should I put?
I try to push to
But problem with context, any trick please?
Click to expand...
Click to collapse
The correct way is without Xposed! Use the Android BOOT_COMPLETED broadcast.

Categories

Resources