Android Quick shortcuts [passing intent extra(or some data) in shortcuts.xml ] - android-shortcut

While implementing the static Shortcuts using shortcut.xml, i would like to pass few bundle extras with my intent.
need the passed extras to decide on few functionality in the target class after launching the app.
is it possible to access the extras? how and where to access it?
Any leads would be highly appreciated

I'm not sure if there is another way, but I use this:
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="target.package"
android:targetClass="activity.with.package">
<extra android:name="extraID" android:value="extravalue" />
</intent>
Then you can access extras as usual.

Than why don't you create dynamic shortcuts?
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
Intent thirdIntent = new Intent(this,ThirdActivity.class);
thirdIntent.setAction(Intent.ACTION_VIEW);
ShortcutInfo thirdScreenShortcut = new ShortcutInfo.Builder(this, "shortcut_third")
.setShortLabel("Third Activity")
.setLongLabel("This is long description for Third Activity")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setIntent(thirdIntent)
.build();
shortcutManager.setDynamicShortcuts(Collections.singletonList(thirdScreenShortcut));
You can pass whatever you want to send in Intent and access it to receiver activity.

Related

discordpy 2.0 interaction is a required argument that is missing

#client.command(brief="Send a message with a button!")
async def button(ctx,interaction: discord.Interaction):
view = discord.ui.View()
style = discord.ButtonStyle.gray
item = discord.ui.Button(style=style, label="Read the docs!", url="https://discordpy.readthedocs.io/en/master")
view.add_item(item=item)
await interaction.response.send_message("This message has buttons!", view=view)
await interaction.response.send_message(content="Hi", ephemeral=True)
discord.ext.commands.errors.MissingRequiredArgument: interaction is a required argument that is missing.
Actually i just want to send a message by intraction, but seem itwasn't work :(
I think you are confused about the basic concepts since your code is mixed up command and interaction stuffs.
If you want to create button, you cannot write in the older command way like #client.command. You need to either use application command or hybrid command (which is a mix of interaction and command)
So, you should never have something like (ctx: Context, interaction: Interaction) together.
Also, classically, you need to create a view class and create a button inside this view class. Then you can attach this view to your message or embed when you send this to the user.
And, if you want to respond to user multiple times in a application command, you cannot do that through interaction.response (only once). You can use interaction.followup() for later responses. link
For view examples, see file example under this
For slash command (application command) example, see this

How to focus on multiple windows

I am currently working on selenium using ruby.
Is there any way to focus on a new window from an application?
Thanks!
I'm not aware of Ruby, but this what you can do in JAVA. See if you can implement similar logic in RUBY.
String parentHandle= driver.getWindowHandle();//Return parent window handle
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
}
driver.close(); // close newly opened window
driver.switchTo().window(parentHandle); // switch back to the parent window
Unfortunately, I cannot leave comments, or else I would point you to both of these websites:
API examples: http://docs.seleniumhq.org/docs/03_webdriver.jsp -> ruby option
API docs: http://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/Window.html
http://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/Driver.html
Here is a direct translation of the code by abhijeet in case you are wondering how it may look like in ruby.
parent_handle = driver.window_handle
driver.window_handles.each do |handle|
driver.switch_to.window handle
end
driver.close
driver.switch_to.window(parent_handle)

AX2012 - Pre-Processed RecId parameter not found

I made a custom report in AX2012, to replace the WHS Shipping pick list. The custom report is RDP based. I have no trouble running it directly (with the parameters dialog), but when I try to use the controller (WHSPickListShippingController), I get an error saying "Pre-Processed RecId not found. Cannot process report. Indicates a development error."
The error is because in the class SrsReportProviderQueryBuilder (setArgs method), the map variable reportProviderParameters is empty. I have no idea why that is. The code in my Data provider runs okay. Here is my code for running the report :
WHSWorkId id = 'LAM-000052';
WHSPickListShippingController controller;
Args args;
WHSShipmentTable whsShipmentTable;
WHSWorkTable whsWorkTable;
clWHSPickListShippingContract contract; //My custom RDP Contract
whsShipmentTable = WHSShipmentTable::find(whsWorkTable.ShipmentId);
args = new Args(ssrsReportStr(WHSPickListShipping, Report));
args.record(whsShipmentTable);
args.parm(whsShipmentTable.LoadId);
contract = new clWHSPickListShippingContract();
controller = new WHSPickListShippingController();
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
controller.parmArgs(args);
controller.startOperation();
I don't know if I'm clear enough... But I've been looking for a fix for hours without success, so I thought I'd ask here. Is there a reason why this variable (which comes from the method parameter AifQueryBuilderArgs) would be empty?
I'm thinking your issue is with these lines (try removing):
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
The style I'd expect to see with your contract would be like this:
controller = new WHSPickListShippingController();
contract = controller.getDataContractObject();
contract.parmWhatever('ParametersHere');
controller.parmArgs(args);
And for the DataProvider clWHSPickListShippingDP, usually if a report is using a DataProvider, you don't manually set it, but the DP extends SRSReportDataProviderBase and has an attribute SRSReportParameterAttribute(...) decorating the class declaration in this style:
[SRSReportParameterAttribute(classstr(MyCustomContract))]
class MyCustomDP extends SRSReportDataProviderBase
{
// Vars
}
You are using controller.parmReportContract().parmRdpContract(contract); wrong, as this is more for run-time modifications. It's typically used for accessing the contract for preRunModifyContract overloads.
Build your CrossReference in a development environment then right click on \Classes\SrsReportDataContract\parmRdpContract and click Add-Ins>Cross-reference>Used By to see how that is generally used.
Ok, so now I feel very stupid for spending so much time on that error, when it's such a tiny thing...
The erronous line is that one :
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
Because WHSPickListShipping is the name of the AX report, but I renamed my custom report clWHSPickListShipping. What confused me was that my DataProvider class was executing as wanted.

Calling checkCurrentDictionary() from addon crashes FF - why?

I'm tyring to call the method checkCurrentDictionary() of nsIEditorSpellCheck from within an add-on. The relevant code I use is:
var editorSpellCheck = Cc["#mozilla.org/editor/editorspellchecker;1"].createInstance(Ci.nsIEditorSpellCheck);
editorSpellCheck.checkCurrentDictionary();
This immediately crashes the Fx. What is going wrong here?
So this probably has something to do with the fact that nsIEditorSpellCheck is not a scriptable interface.
Basically, a scriptable interface is one that can be used from JavaScript.
If you want to access the spell check service you can do something like:
let editor = editableElement.editor;
if (!editor) {
let win = editableElement.ownerDocument.defaultView;
editor = win.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIEditingSession).
getEditorForWindow(win);
}
if (!editor)
throw new Error("Unable to find editor for element " + editableElement);
(The above is from http://dxr.mozilla.org/mozilla-central/source/editor/AsyncSpellCheckTestHelper.jsm which is MPL).
Then you can use the InlineSpellCheck.jsm to do some crazy stuff.
I'm not sure what you want to do though, so perhaps you should ask that more specific question as a new question.

Is it Possible to have more than one messages file in Play framework

We have a site which will be used for two different clients. During first request the user will be asked to choose a client. Based on that text,labels and site content should be displayed.
Is it possible to have two messages file in Play framework and during session startup the messages file would be decided
As of my research we can have more than a file for each Locale, the messages will be get based on locale in the request.
No, it is not supported at the moment.
You can easily do that either in a plugin(Look at MessagesPlugin ) or even using a bootstrap job with the #onApplicationStartup annotation
// From MessagesPlugin.java
//default languange messages
VirtualFile appDM = Play.getVirtualFile("conf/messages");
if(appDM != null && appDM.exists()) {
Messages.defaults.putAll(read(appDM));
}
static Properties read(VirtualFile vf) {
if (vf != null) {
return IO.readUtf8Properties(vf.inputstream());
}
return null;
}
You can wrote you own PlayPlugin and handle implement play.PlayPlugin.getMessage(String, Object, Object...). Then you could choose the right file. The class play.i18n.Messages can be used as inspiration how to implement the method.
Solved this problem with below solution,
Created a class MessagesPlugIn which extends play.i18n.MessagesPlugin
Created a class Messages as like play.i18n.Messages
Had a static Map messaagesByClientID in Messages.java
Overridden onApplicationStart() in MessagesPlugIn
Loaded the Properties in messaagesByClientID as locales loaded in play.i18n.MessagesPlugin
Had a method get() in Messages.java, retrieve the property from messaagesByClientID based ClientId in the session. If the property is not available call get() in play.i18n.Messages
7.Created a Custom tag il8nTag and its used in HTML templates. il8nTag will invoke the methos in Messages.get().
Create your own Module based on play.api.i18n.I18nModule, but bound to your own implementation of MessagesApi, based on Play's DefaultMessagesApi (here is the part defining the files to load)
Then in your application.conf, disable Play's play.api.i18n.I18nModule and enable your own module.

Resources