应用内无法使用意图

时间:2018-08-28 08:03:03

标签: java android android-intent

我有一个意图com.amazon.tv.settings/.hud.HudActivity,我可以在Amazon Fire TV v3上使用adb shell am start -n "com.amazon.tv.settings/.hud.HudActivity"通过adb启动它。 但是,当我通过代码启动相同的意图时:

getApplicationContext().startActivity(new Intent("com.amazon.tv.settings/.hud.HudActivity"));

无法找到产生错误的活动:

E/AndroidRuntime: FATAL EXCEPTION: Timer-0
                  Process: com.baronkiko.launcherhijack, PID: 23262
                  android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.amazon.tv.settings/.hud.HudActivity }
                      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
                      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
                      at android.app.ContextImpl.startActivity(ContextImpl.java:820)
                      at android.app.ContextImpl.startActivity(ContextImpl.java:797)
                      at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
                      at com.baronkiko.launcherhijack.AccServ$1.run(AccServ.java:111)
                      at java.util.TimerThread.mainLoop(Timer.java:555)
                      at java.util.TimerThread.run(Timer.java:505)

这是我真正需要的系统意图。如何启动此意图,我是否需要更多权限? 我很感激我会收到的任何帮助。

2 个答案:

答案 0 :(得分:1)

请尝试以下操作:

dl-file.php

致电时

<?php
ob_start();
require_once('wp-load.php');
require_once ABSPATH . WPINC . '/formatting.php';
require_once ABSPATH . WPINC . '/capabilities.php';
require_once ABSPATH . WPINC . '/user.php';
require_once ABSPATH . WPINC . '/meta.php';
require_once ABSPATH . WPINC . '/post.php';
require_once ABSPATH . WPINC . '/pluggable.php';
wp_cookie_constants();
$discard = ob_get_clean();

is_user_logged_in() ||  auth_redirect();


list($basedir) = array_values(array_intersect_key(wp_upload_dir(), array('basedir' => 1)))+array(NULL);

$file = rtrim($basedir, '/') . '/' . (isset($_GET['file']) ? $_GET['file'] : '');
$file = realpath($file);

if ($file === FALSE || !$basedir || !is_file($file)) {
    status_header(404);
    die('404 &#8212; File not found.');
}

if (strpos($file, $basedir) !== 0) {
    status_header(403);
    die('403 &#8212; Access denied.');
}


$mime = wp_check_filetype($file);
if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
    $mime[ 'type' ] = mime_content_type( $file );
if( $mime[ 'type' ] )
    $mimetype = $mime[ 'type' ];
else
    $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
header( 'Content-Type: ' . $mimetype ); // always send this
if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
    header( 'Content-Length: ' . filesize( $file ) );
$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
$etag = '"' . md5( $last_modified ) . '"';
header( "Last-Modified: $last_modified GMT" );
header( 'ETag: ' . $etag );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
// Support for Conditional GET
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
    $_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
// If string is empty, return 0. If not, attempt to parse into a timestamp
$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
// Make a timestamp for our most recent modification...
$modified_timestamp = strtotime($last_modified);
if ( ( $client_last_modified && $client_etag )
    ? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
    : ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
    ) {
    status_header( 304 );
    exit;
}
// If we made it this far, just serve the file
readfile( $file );

“ com.amazon.tv.settings / .hud.HudActivity”被视为操作而不是类名。

答案 1 :(得分:1)

您可以使用以下代码创建适当的Intent:

getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.amazon.tv.settings/.hud.HudActivity");