com.android.ide.common.xml.AndroidManifestParser Java Examples
The following examples show how to use
com.android.ide.common.xml.AndroidManifestParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectManager.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public static AndroidProjectFolder importAndroidProject(Context context, File file) { Log.d(TAG, "importAndroidProject() called with: context = [" + context + "], file = [" + file + "]"); AndroidProjectFolder project = new AndroidProjectFolder(file.getParentFile(), null, null, file.getName()); try { if (project.getXmlManifest().exists()) { ManifestData manifestData = AndroidManifestParser.parse(new FileInputStream(project.getXmlManifest())); ManifestData.Activity launcherActivity = manifestData.getLauncherActivity(); if (launcherActivity != null) { project.setMainClass(new ClassFile(launcherActivity.getName())); project.setPackageName(manifestData.getPackage()); } Log.d(TAG, "importAndroidProject launcherActivity = " + launcherActivity); } else { return null; } if (project.getKeyStore().getFile().exists()) { project.checkKeyStoreExits(context); } return project; } catch (Exception e) { } return null; }
Example #2
Source File: AtlasSymbolIo.java From atlas with Apache License 2.0 | 6 votes |
/** * Writes the symbol table with the package name as the first line. * * @param symbolTable The R.txt file. If it does not exist, the result will be a file containing * only the package name * @param manifest The AndroidManifest.xml file for this library. The package name is extracted * and written as the first line of the output. * @param outputFile The file to write the result to. */ public static void writeSymbolTableWithPackage( @NonNull Path symbolTable, @NonNull Path manifest, @NonNull Path outputFile) throws IOException { @Nullable String packageName; try (InputStream is = new BufferedInputStream(Files.newInputStream(manifest))) { packageName = AndroidManifestParser.parse(is).getPackage(); } catch (SAXException | ParserConfigurationException e) { throw new IOException(e); } try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(outputFile))) { if (packageName != null) { os.write(packageName.getBytes(Charsets.UTF_8)); } os.write('\n'); if (!Files.exists(symbolTable)) { return; } try (InputStream is = new BufferedInputStream(Files.newInputStream(symbolTable))) { ByteStreams.copy(is, os); } } }
Example #3
Source File: AndroidProjectFolder.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Nullable public ManifestData.Activity getLauncherActivity() { try { ManifestData manifestData = AndroidManifestParser.parse(new FileInputStream(getXmlManifest())); ManifestData.Activity launcherActivity = manifestData.getLauncherActivity(); this.launcherActivity = launcherActivity; return launcherActivity; } catch (Exception e) { return null; } }
Example #4
Source File: AndroidLibraryProject.java From javaide with GNU General Public License v3.0 | 5 votes |
private void parseAndroidManifest() throws IOException, SAXException, StreamException, ParserConfigurationException { xmlManifest = new File(dirRoot, "AndroidManifest.xml"); if (!xmlManifest.exists()) { throw new FileNotFoundException(xmlManifest + " not exist"); } ManifestData manifestData = AndroidManifestParser.parse(new FileInputStream(xmlManifest)); String aPackage = manifestData.getPackage(); setPackageName(aPackage); }
Example #5
Source File: AndroidAppProject.java From javaide with GNU General Public License v3.0 | 5 votes |
@Nullable public ManifestData.Activity getLauncherActivity() { try { ManifestData manifestData = AndroidManifestParser.parse(new FileInputStream(getManifestFile())); ManifestData.Activity launcherActivity = manifestData.getLauncherActivity(); this.launcherActivity = launcherActivity; return launcherActivity; } catch (Exception e) { return null; } }
Example #6
Source File: ResourceShrinkerAction.java From bazel with Apache License 2.0 | 4 votes |
private static String getManifestPackage(Path manifest) throws SAXException, IOException, StreamException, ParserConfigurationException { ManifestData manifestData = AndroidManifestParser.parse(Files.newInputStream(manifest)); return manifestData.getPackage(); }