I am new to windows programming
I wanted to start the notification system of my program with the documents I saw from Microsoft
It works fine when I use ready-made templates
XmlDocument doc= ToastNotificationManager::GetTemplateContent(ToastTemplateType::ToastText02);
doc.SelectSingleNode(L"//text[1]").InnerText(L"Hellow :D");
doc.SelectSingleNode(L"//text[2]").InnerText(L"Im greate :X:X:X");
ToastNotification notif{doc};
toastNotifier_.Show(notif);
But when I make my own template it doesn't work
std::ifstream tro(address);
std::string str((std::istreambuf_iterator<char>(tro)),
std::istreambuf_iterator<char>());
XmlDocument doc;
doc.LoadXml(winrt::to_hstring(str));
doc.SelectSingleNode(L"//text[1]").InnerText(L"Hellow :D");
doc.SelectSingleNode(L"//text[2]").InnerText(L"Im greate :X:X:X");
ToastNotification notif{doc};
toastNotifier_.Show(notif);
XML file
<toast>
<visual>
<binding template="ToastGeneric">
<text id="1"></text>
<text id="2"></text>
</binding>
</visual>
</toast>
I noticed something, when I change the template attribute name from ToastGeneric to one of the ready template names like ToastText02, the notification is displayed, but the information is not placed in the children.
add activationType to toast solve this issue
<toast activationType="protocol"> // protocol,Background,Foreground
<visual>
<binding template="ToastGeneric">
<text id="1"></text>
<text id="2"></text>
</binding>
</visual>
</toast>
Related
The NotificationsExtensions::TileContent in windows 8.1 doesn't work in windows 10.
Therefore, I am using TileUpdateManager for live tiles, but live tiles doesn't work.
I am using struct like below for TileUpdateManager :
<tile>
<visual version='3'>
<binding template='TileSquare310x310Image' branding='name'>
<image id='1' src='ms-appx:///Assets/Tiles/310x310.png' alt='' />
</binding>
</visual>
</tile>
Is it the right way to use TileUpdateManager for live tiles?
What can I use to update live tiles like NotificationsExtensions::TileContent in windows 8.1?
Yes TileUpdateManager is the way to do it in Windows 10. Below is a small snippet in C#
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
updater.EnableNotificationQueue(true);
XmlDocument document = new XmlDocument();
document.LoadXml(content); 'content is your xml'
TileNotification notification = new TileNotification(document);
updater.Update(notification);
I have the following xml file
<applications>
<application>
<forms>
<questions>
<first_name>
My Name
</first_name>
</questions>
</forms>
</application>
</applications>
First I have a for each loop which runs through all applications and assigns a variable app to a current application. Then I test each application like this:
<wr:if select="${app}/forms/questions/first_name" notEmpty="true">Print this if succeeded</wr:if>
I am trying to test if there is a text in first_name tag, but in the end I always have empty string, I guess my if does not succeed. Do you know if I made a mistake in my xpath?
Try to use text():
<wr:if select="${app}/forms/questions/first_name/text()" notEmpty="true">Print this if succeeded</wr:if>
Is there a way to nest voice triggers when launching an app on Google Glass using the GDK? For example instead of just saying "ok, glass" -> "What's its power level?" I'd like to have the app present an option. For example "ok, glass" -> "What's its power level?" -> "Over 9000" OR "Under 9000". Any help would be great!
If you have multiple activities/services installed on Glass that have the same voice trigger intent filter, all of their names (based on the android:label attribute of the <activity> or <service> tag in AndroidManifest.xml) will appear in a disambiguation "submenu" when you speak that voice trigger.
For example (assume that res/xml/play_a_game_trigger.xml represents a voice trigger for the string "play a game"):
<activity android:label="Tennis">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/play_a_game_trigger" />
</activity>
<activity android:label="Bowling">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/play_a_game_trigger" />
</activity>
would give you a voice menu flow that looks like
ok glass → play a game → Tennis
Bowling
Do note, however, that this menu would also include activities/services from other APKs that use the same voice trigger as well.
You can find more details at the Voice Input page of the GDK documentation.
The proper way to do this is using an input tag inside the trigger
<trigger keyword="#string/start_app" >
<input prompt="#string/promt_text" />
</trigger>
This prompts an input and waits for more audio speech.
Then in your activity you can capture this text with:
ArrayList<String> text = getIntent().getExtras().getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
I am trying to understand fragments. All the examples I read is about having a main activity and then two sub fragments.
The issue is that my program has only 1 activity. Can I make it a fragment?
Current ui main class
public class MainActivity extends Activity {}
Can I make it
public class MainActivity extends Fragment {}
The program I am trying to create will constantly monitor phone variables and display logs in a textView. I don't want to lose the logs when the user changes the orientation or some other change when the os destroys the ui.
The UI is basically 1 textView that gets filled by a runnable that updates the textView every 5 seconds with the content of a linked list. I don't want to lose the content of the linked list basically.
I checked getLastNonConfigurationInstance() but it seems it's depreciated so I don't want to use that
Any help would be highly appreciated.
Amish
Found answer here:
http://blog.webagesolutions.com/archives/458
So after a lot of searching I found that if you add the following:
android:configChanges="orientation|screenSize"
in the androidManifest.xml, the os will not destroy the activity when switching from portrait mode to landscape mode.
My xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.axr0284.phonecontrol"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.axr0284.phonecontrol.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Hope this helps somebody,
Amish
I have a Metro app in C# & XAML. The tile is updated periodically and I've used WebAPI to serve the tile notification XML. So far so good. I was then told that I cannot use WebAPI as the server that I was planning to host it on does not have .NET 4.5. No plans to install it anytime soon either. I had to change the WebAPI to a plain old Web service (.NET 3.5) which does the same thing - return tile notification XML. I've enabled HTTP-GET (I know, security concern) and was able to invoke the webservice like this -
http://server/TileNotifications.asmx/GetTileData?user=user#domain.com
But ever since I made the switch, the tiles are not being updated. I've checked Fiddler and made sure the app is hitting the webservice and the XML is being returned correctly. But the tiles are not updated. If I replace it with the WebAPI, the tiles are updated.
Do I need to do anything special with the web services? like decorating the web method with a custom attribute? Here's my web service code -
[WebMethod]
public XmlDocument GetTileData(string user)
{
// snip
var xml = new XmlDocument();
xml.LoadXml(string.Format(#"<tile>
<visual>
<binding template='TileWideSmallImageAndText02'>
<image id='1' src='http://server/images/{0}_wide.png'/>
<text id='1'>Custom Field : {1}/text>
<text id='2'>Custom Field : {2}</text>
<text id='3'>Custom Field : {3}</text>
</binding>
<binding template='TileSquarePeekImageAndText01'>
<image id='1' src='http://server/images/{0}_square.png'/>
<text id='1'>Custom Field</text>
<text id='2'>{1}</text>
</binding>
</visual>
</tile>", value1, value2, value3, value4));
return xml;
}