How to use getData method of io.appium.java_client.android.options.app.IntentOptions class

Best io.appium code snippet using io.appium.java_client.android.options.app.IntentOptions.getData

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

IntentOptions.java

Source: IntentOptions.java Github

copy
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * See the NOTICE file distributed with this work for additional
5 * information regarding copyright ownership.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package io.appium.java_client.android.options.app;
18
19import io.appium.java_client.remote.options.BaseMapOptionData;
20
21import java.util.List;
22import java.util.Map;
23import java.util.Optional;
24import java.util.function.Function;
25import java.util.stream.Collectors;
26
27public class IntentOptions extends BaseMapOptionData<IntentOptions> {
28    public IntentOptions() {
29        super();
30    }
31
32    public IntentOptions(Map<String, Object> options) {
33        super(options);
34    }
35
36    /**
37     * An intent action name. Application-specific actions should be prefixed with
38     * the vendor's package name.
39     *
40     * @param action E.g. ACTION_MAIN.
41     * @return self instance for chaining.
42     */
43    public IntentOptions withAction(String action) {
44        return assignOptionValue("action", action);
45    }
46
47    /**
48     * Get the action name.
49     *
50     * @return Action name.
51     */
52    public Optional<String> getAction() {
53        return getOptionValue("action");
54    }
55
56    /**
57     * Set an intent data URI.
58     *
59     * @param data E.g. content://contacts/people/1.
60     * @return self instance for chaining.
61     */
62    public IntentOptions withData(String data) {
63        return assignOptionValue("data", data);
64    }
65
66    /**
67     * Get intent data URI.
68     *
69     * @return Intent data URI.
70     */
71    public Optional<String> getData() {
72        return getOptionValue("data");
73    }
74
75    /**
76     * Intent MIME type.
77     *
78     * @param type E.g. image/png.
79     * @return self instance for chaining.
80     */
81    public IntentOptions withType(String type) {
82        return assignOptionValue("type", type);
83    }
84
85    /**
86     * Get an intent type.
87     *
88     * @return Intent type.
89     */
90    public Optional<String> getType() {
91        return getOptionValue("type");
92    }
93
94    /**
95     * Set intent categories.
96     *
97     * @param categories One or more comma-separated Intent categories.
98     * @return self instance for chaining.
99     */
100    public IntentOptions withCategories(String categories) {
101        return assignOptionValue("categories", categories);
102    }
103
104    /**
105     * Get intent categories.
106     *
107     * @return Intent categories.
108     */
109    public Optional<String> getCategories() {
110        return getOptionValue("categories");
111    }
112
113    /**
114     * Set intent component name with package name prefix
115     * to create an explicit intent.
116     *
117     * @param component E.g. com.example.app/.ExampleActivity.
118     * @return self instance for chaining.
119     */
120    public IntentOptions withComponent(String component) {
121        return assignOptionValue("component", component);
122    }
123
124    /**
125     * Get intent component name.
126     *
127     * @return Intent component name.
128     */
129    public Optional<String> getComponent() {
130        return getOptionValue("component");
131    }
132
133    /**
134     * Single-string value, which represents intent flags set encoded into
135     * an integer. Could also be provided in hexadecimal format. Check
136     * https://developer.android.com/reference/android/content/Intent.html#setFlags(int)
137     * for more details.
138     *
139     * @param intFlags E.g. 0x0F.
140     * @return self instance for chaining.
141     */
142    public IntentOptions withIntFlags(String intFlags) {
143        return assignOptionValue("intFlags", intFlags);
144    }
145
146    /**
147     * Get intent flags.
148     *
149     * @return Intent flags encoded into a hexadecimal value.
150     */
151    public Optional<String> getIntFlags() {
152        return getOptionValue("intFlags");
153    }
154
155    /**
156     * Comma-separated string of intent flag names.
157     *
158     * @param flags E.g. 'ACTIVITY_CLEAR_TASK' (the 'FLAG_' prefix is optional).
159     * @return self instance for chaining.
160     */
161    public IntentOptions withFlags(String flags) {
162        return assignOptionValue("flags", flags);
163    }
164
165    /**
166     * Get intent flag names.
167     *
168     * @return Comma-separated string of intent flag names.
169     */
170    public Optional<String> getFlags() {
171        return getOptionValue("flags");
172    }
173
174    /**
175     * The name of a class inside of the application package that
176     * will be used as the component for this Intent.
177     *
178     * @param className E.g. com.example.app.MainActivity.
179     * @return self instance for chaining.
180     */
181    public IntentOptions withClassName(String className) {
182        return assignOptionValue("className", className);
183    }
184
185    /**
186     * Get class name.
187     *
188     * @return Class name.
189     */
190    public Optional<String> getClassName() {
191        return getOptionValue("className");
192    }
193
194    /**
195     * Intent string parameters.
196     *
197     * @param es Map, where the key is arg parameter name and value is its string value.
198     * @return self instance for chaining.
199     */
200    public IntentOptions withEs(Map<String, String> es) {
201        return assignOptionValue("es", es);
202    }
203
204    /**
205     * Get intent string parameters.
206     *
207     * @return Intent string parameters mapping.
208     */
209    public Optional<Map<String, String>> getEs() {
210        return getOptionValue("es");
211    }
212
213    /**
214     * Intent null parameters.
215     *
216     * @param esn List, where keys are parameter names.
217     * @return self instance for chaining.
218     */
219    public IntentOptions withEsn(List<String> esn) {
220        return assignOptionValue("esn", esn);
221    }
222
223    /**
224     * Get intent null parameters.
225     *
226     * @return Intent null parameters.
227     */
228    public Optional<List<String>> getEsn() {
229        return getOptionValue("esn");
230    }
231
232    /**
233     * Intent boolean parameters.
234     *
235     * @param ez Map, where keys are parameter names and values are booleans.
236     * @return self instance for chaining.
237     */
238    public IntentOptions withEz(Map<String, Boolean> ez) {
239        return assignOptionValue("ez", ez);
240    }
241
242    /**
243     * Get intent boolean parameters.
244     *
245     * @return Intent boolean parameters.
246     */
247    public Optional<Map<String, Boolean>> getEz() {
248        return getOptionValue("ez");
249    }
250
251    /**
252     * Intent integer parameters.
253     *
254     * @param ei Map, where keys are parameter names and values are integers.
255     * @return self instance for chaining.
256     */
257    public IntentOptions withEi(Map<String, Integer> ei) {
258        return assignOptionValue("ei", ei);
259    }
260
261    private <T> Map<String, T> convertMapValues(Map<String, Object> map, Function<String, T> converter) {
262        return map.entrySet().stream()
263                .collect(Collectors.toMap(
264                        Map.Entry::getKey, (entry) -> converter.apply(String.valueOf(entry.getValue())))
265                );
266    }
267
268    /**
269     * Get intent integer parameters.
270     *
271     * @return Intent integer parameters.
272     */
273    public Optional<Map<String, Integer>> getEi() {
274        Optional<Map<String, Object>> value = getOptionValue("ei");
275        return value.map((v) -> convertMapValues(v, Integer::parseInt));
276    }
277
278    /**
279     * Intent long parameters.
280     *
281     * @param el Map, where keys are parameter names and values are long numbers.
282     * @return self instance for chaining.
283     */
284    public IntentOptions withEl(Map<String, Long> el) {
285        return assignOptionValue("el", el);
286    }
287
288    /**
289     * Get intent long parameters.
290     *
291     * @return Intent long parameters.
292     */
293    public Optional<Map<String, Long>> getEl() {
294        Optional<Map<String, Object>> value = getOptionValue("el");
295        return value.map((v) -> convertMapValues(v, Long::parseLong));
296    }
297
298    /**
299     * Intent float parameters.
300     *
301     * @param ef Map, where keys are parameter names and values are float numbers.
302     * @return self instance for chaining.
303     */
304    public IntentOptions withEf(Map<String, Float> ef) {
305        return assignOptionValue("ef", ef);
306    }
307
308    /**
309     * Get intent float parameters.
310     *
311     * @return Intent float parameters.
312     */
313    public Optional<Map<String, Float>> getEf() {
314        Optional<Map<String, Object>> value = getOptionValue("ef");
315        return value.map((v) -> convertMapValues(v, Float::parseFloat));
316    }
317
318    /**
319     * Intent URI-data parameters.
320     *
321     * @param eu Map, where keys are parameter names and values are valid URIs.
322     * @return self instance for chaining.
323     */
324    public IntentOptions withEu(Map<String, String> eu) {
325        return assignOptionValue("eu", eu);
326    }
327
328    /**
329     * Get intent URI parameters.
330     *
331     * @return Intent URI parameters.
332     */
333    public Optional<Map<String, String>> getEu() {
334        return getOptionValue("eu");
335    }
336
337    /**
338     * Intent component name parameters.
339     *
340     * @param ecn Map, where keys are parameter names and values are valid component names.
341     * @return self instance for chaining.
342     */
343    public IntentOptions withEcn(Map<String, String> ecn) {
344        return assignOptionValue("ecn", ecn);
345    }
346
347    /**
348     * Get intent component name parameters.
349     *
350     * @return Intent component name parameters.
351     */
352    public Optional<Map<String, String>> getEcn() {
353        return getOptionValue("ecn");
354    }
355
356    private static Map<String, String> mergeValues(Map<String, ?> map) {
357        return map.entrySet().stream()
358                .collect(
359                        Collectors.toMap(Map.Entry::getKey, (entry) -> ((List<?>) entry.getValue()).stream()
360                                .map(String::valueOf)
361                                .collect(Collectors.joining(",")))
362                );
363    }
364
365    /**
366     * Intent integer array parameters.
367     *
368     * @param eia Map, where keys are parameter names and values are lists of integers.
369     * @return self instance for chaining.
370     */
371    public IntentOptions withEia(Map<String, List<Integer>> eia) {
372        return assignOptionValue("eia", mergeValues(eia));
373    }
374
375    /**
376     * Get intent integer array parameters.
377     *
378     * @return Intent integer array parameters.
379     */
380    public Optional<Map<String, String>> getEia() {
381        return getOptionValue("eia");
382    }
383
384    /**
385     * Intent long array parameters.
386     *
387     * @param ela Map, where keys are parameter names and values are lists of long numbers.
388     * @return self instance for chaining.
389     */
390    public IntentOptions withEla(Map<String, List<Long>> ela) {
391        return assignOptionValue("ela", mergeValues(ela));
392    }
393
394    /**
395     * Get intent long array parameters.
396     *
397     * @return Intent long array parameters.
398     */
399    public Optional<Map<String, String>> getEla() {
400        return getOptionValue("ela");
401    }
402
403    /**
404     * Intent float array parameters.
405     *
406     * @param efa Map, where keys are parameter names and values are lists of float numbers.
407     * @return self instance for chaining.
408     */
409    public IntentOptions withEfa(Map<String, List<Float>> efa) {
410        return assignOptionValue("efa", mergeValues(efa));
411    }
412
413    /**
414     * Get intent float array parameters.
415     *
416     * @return Intent float array parameters.
417     */
418    public Optional<Map<String, String>> getEfa() {
419        return getOptionValue("efa");
420    }
421}
422
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger getData code on LambdaTest Cloud Grid

Execute automation tests with getData on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)