How to set android.app.default_searchable meta data tag in abstract base class activity - android-actionbar

i am creating an abstract base class activity for options menu. i am extending my main activity with the base activity. in the manifest file i placed the metadata tag like below
Manifest:
<activity
android:name="com.schoolinsites.mcpss.BaseActivity" >
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsActivity" />
</activity>
<activity
android:name="com.schoolinsites.mcpss.MainActivity"
android:label="#string/app_name"
>
</activity>
my main activity is extending from the Base activity .if i search from the mainactivity i am not able go to the search activity but if i place the metadata tag in the Mainactivity i am able to move the search activity. how can i place the meta data tag in the Baseactivity.

That's not possible since the BaseActivity isn't launched as a Activity but the MainAcitivty is.

Related

how can I deeplink an app from Google Assistant?

I'm creating a dialogflow agent integrated with Google Assistant.
What I'd like to do is to open an app (my app) when a proper intent is matched. I've seen that actions like Youtube, Spotify etc. are able to do that, for example I can tell the Youtube action "search for cats video" and the Youtube app will open with a list of cats videos.
I tried to use the DeepLink class but I then noticed it's deprecated.
DeepLink class
Is there any way you can suggest me to do this?
Thanks in advance
I think you are looking for App Actions. Here are the steps you need to follow:
Find the right built-in intent. actions.intent.OPEN_APP_FEATURE should be the right one for you.
Create and update actions.xml. It should look like
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.OPEN_APP_FEATURE">
<!-- Use url from inventory match for deep link fulfillment -->
<fulfillment urlTemplate="{#url}" />
<!-- Define parameters with inventories here -->
<parameter name="feature">
<entity-set-reference entitySetId="featureParamEntitySet" />
</parameter>
</action>
<entity-set entitySetId="featureParamEntitySet">
<!-- Provide a URL per entity -->
<entity url="myapp://deeplink/one" name="featureParam_one" alternateName="#array/featureParam_one_synonyms" />
<entity url="myapp://deeplink/two" name="featureParam_two" alternateName="#array/featureParam_two_synonyms" />
</entity-set>
</actions>

Way to nest multiple voice triggers when launching an app with GDK

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);

keeping data during orientation changes by using fragments

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

Disable Sitecore's Html cache for one item

I want to disable the html cache for 1 item so it is always rendered.
Background:
I need to show information for companies stored in a separate database. In sitecore I have 1 item which has the user control that shows the required information and depending on a Context parameter I figure out which company to show.
The sitecore tree look like this:
/sitecore
/content
/home
/company-information
The url is: /show-company-information/[company-name]-[company-id]. I have a pipeline module that parses the url and sets the company information as the current item and adds the company id to HttpContext.Current.Items. That's how my user control figures out which company information to render.
It all works fine in development but once you deploy it to a Content Delivery server it stops working correctly. The first time the page is accessed it gets cached and every consecutive request returns the company information that was cached the first time.
My current workaround is to clear the HTML cache for the company-info item in the same pipeline step that parses the company-information but it seems a really dirty solution.
Is there a better way to achieve the same result?
EDIT
Here is how the site is setup in web.config and also the web database configuration:
<site name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/Home/" startItem="/home" language="en-GB" database="web" domain="extranet" loginPage="/user-login.aspx" allowDebug="true" cacheHtml="true" htmlCacheSize="400MB" registryCacheSize="500KB" viewStateCacheSize="500KB" xslCacheSize="20MB" filteredItemsCacheSize="20MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" />
<!-- CACHE SIZES -->
<cacheSizes>
<sites>
<website>
<html>500MB</html>
<registry>500KB</registry>
<viewState>500KB</viewState>
<xsl>200MB</xsl>
</website>
</sites>
</cacheSizes>
<database id="web" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
<param desc="name">$(id)</param>
<icon>Network/16x16/earth.png</icon>
<securityEnabled>true</securityEnabled>
<dataProviders hint="list:AddDataProvider">
<dataProvider ref="dataProviders/main" param1="$(id)">
<disableGroup>publishing</disableGroup>
<prefetch hint="raw:AddPrefetch">
<sc.include file="/App_Config/Prefetch/Common.config" />
<sc.include file="/App_Config/Prefetch/Web.config" />
</prefetch>
</dataProvider>
</dataProviders>
<indexes hint="list:AddIndex">
<index path="indexes/index[#id='articleIndex']" />
</indexes>
<proxiesEnabled>false</proxiesEnabled>
<proxyDataProvider ref="proxyDataProviders/main" param1="$(id)" />
<archives hint="raw:AddArchive">
<archive name="archive" />
<archive name="recyclebin" />
</archives>
<Engines.HistoryEngine.Storage>
<obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
<param connectionStringName="$(id)" />
<EntryLifeTime>30.00:00:00</EntryLifeTime>
</obj>
</Engines.HistoryEngine.Storage>
<cacheSizes hint="setting">
<data>400MB</data>
<items>400MB</items>
<paths>10MB</paths>
<standardValues>1MB</standardValues>
</cacheSizes>
</database>
</databases>
Page layouts structure:
layout - no output caching
- sublayout - no caching options ticked
- offending sublayout - no caching options ticked
Are we doing anything wrong for this to be cached so aggressively?
You can use the CacheManager to turn off caching during the Page Load event then turn it back on in PreRender. This will ensure that the page's html / xslt controls are not cached.
The CacheManager Class has the following method used by all controls when retrieving HTML caches
/// <summary>
/// Gets the HTML cache.
/// </summary>
/// <param name="site">The site.</param>
/// <returns>The HTML cache.</returns>
public static HtmlCache GetHtmlCache(SiteContext site)
{
if (_enabled && (site != null))
{
return site.Caches.HtmlCache;
}
return null;
}
So setting the Enabled Property to false will stop the controls being rendered from the cache:
CacheManager.Enabled = false;
Its brutal but it works.
If your HTML is being cached, its from a specific rendering, e.g. a specific sublayout. If you have a sublayout set to cache and vary by anything in Layout Details, undo that. Or, you may be doing it in code, in which case you can change your C# to not cache it.
Here's a sublayout in code that is set to cache, you may have something like this that you'd want to not cache:
<sc:Sublayout Path="~/layouts/sublayouts/mycontrol.ascx" Cacheable="true" runat="server" />
If this cache problem is cleared by just publishing any sitecore item, then its safe to assume its the sitecore HTML cache.
Any layout or sublayout with caching enabled will also cache the output any control added within it. So if any parent sublayout of this control or rendering has caching enabled you'll need to disable it.
An easy way to view the cache settings for your page is via the debugger [Start] > [Debug]
Hovering over the controls will allow you to view their resultant cache settings.
If your item is a sublayout, you can disable its rendering cache in the page editor component properties or through the definition of the sublayout item in the Cache section.
For example, I have a search results sublayout with cache disabled.

How do I rename a file using the SharePoint web services?

I have a custom definition for a document library and I am trying to rename documents within the library using only the out of the box web services. Having defined a view with the "Name" field supplied and trying the "LinkFilename", my calls to rename a file are respectively returning a failure or ignoring the new value.
How do I rename a file using the SharePoint web services?
Use the Lists.UpdateListItems web method. The XML request should look like:
<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0">
<Method ID="1" Cmd="Update">
<!-- List item ID of document -->
<Field Name="ID">2</Field>
<!-- Full URL to document -->
<Field Name="FileRef">http://Server/FullUrl/File.doc</Field>
<!-- New filename -->
<Field Name="BaseName">NewName</Field>
</Method>
</Batch>
You should be able to use UpdateListItems. Here's an example.
Per comment: So the actual question is "how do I call a web service?" Take a look a this example. Some more good walkthroughs here.